Scheduled backup MySQL
Put/etc/cron.hourly/
Copy Code code as follows:
#!/bin/bash
Dump=/usr/local/webserver/mysql/bin/mysqldump
out_dir=/data1/backup/
Db_name= database name
db_user= Database User
db_pass= Database Password
#How much of the days of backup most
Days=3
#12 hours ago
mins=720
#Core of script
CD $OUT _dir
Date= ' Date +%y-%m-%d-%h '
Out_sql= "$DATE. SQL"
Tar_sql= "db-$DATE. tar.gz"
$DUMP--default-character-set=utf8--opt-u$db_user-p$db_pass $DB _name > $OUT _sql
TAR-CZF $TAR _sql./$OUT _sql
Rm-f $OUT _sql
Find./-name "db*"-type f-mmin + $MINS-exec rm {} \;
#find./-name "db*"-type f-mtime + $DAYS-exec rm {} \;
Exit 0;
Regular cutting Nginx Access.log, only 3 days before the record
Put/etc/cron.hourly/
Copy Code code as follows:
#!/bin/bash
# This script run at 00:00
# The Nginx logs path
#logs_path = "/usr/local/webserver/nginx/logs/"
Logs_path= "/data1/logs/"
#How much of the days of backup most
Days=3
#Core of script
CD $logs _path
Date= ' Date +%y-%m-%d-%h '
Src_file= "Access.log"
Tar_file= "access-$DATE. tar.gz"
Tar-czf $TAR _file $SRC _file
Rm-f $SRC _file
Find./-name "access-*"-type f-mtime + $DAYS-exec rm {} \;
KILL-USR1 ' Cat/usr/local/webserver/nginx/nginx.pid '
Exit 0;