Daily Used Linux Production Shell Scripts
Daily Used Linux Production Shell Scripts
backup_dir="/path/to/backup"
source_dir="/path/to/source"
threshold=90
username="newuser"
logfile="/path/to/logfile.log"
length=12
file="/path/to/file.txt"
host="example.com"
website="https://example.com"
directory="/path/to/cleanup"
# Remove files older than 7 days in specified directory
find "$directory" -type f -mtime +7 -exec rm {} \;
echo "Old files removed."
output_file="cpu_usage_log.txt"
output_file="system_info.txt"
scheduled_task="/path/to/your_script.sh"
schedule_time="0 2 * * *"
# Schedule a task using cron
echo "$schedule_time $scheduled_task" | crontab -
echo "Task scheduled successfully."
threshold=90
source_dir="/path/to/source"
remote_server="user@remoteserver:/path/to/backup"
file_to_compress="/path/to/file.txt"
database_name="your_database"
output_file="database_backup_$(date +%Y%m%d).sql"
git_repo="/path/to/your/repo"
source_dir="/path/to/source"
destination_dir="/path/to/destination"
# Synchronize directories using rsync
rsync -avz "$source_dir" "$destination_dir"
echo "Directories synchronized successfully."
log_file="/var/log/apache2/access.log"
output_file="system_health_check.txt"
database_name="your_database"
days_to_keep=7
service_name="your_service"
folder_path="/path/to/folder"
backup_dir="/path/to/backups"
max_backups=5
remote_server="user@remote-server"
remote_script="/path/to/remote/script.sh"
network_interface="eth0"