日志切割
#!/bin/bash#cut nginx logsnginx_sbin="/usr/local/openresty/nginx/sbin/nginx"log_files_path="/usr/local/openresty/nginx/logs"cut_log_files_dir="/data/logs"logfilename_array=(www.bbs.com)date=`date +%Y-%m-%d -d "1 days ago"`suffix=".log.gz"ProjectName="BBS"#flush log to disk${nginx_sbin} -s reloadfunction cut_gzip_upload(){ gzipFilename=${log_file_name}"_"${date}${suffix} mv ${log_files_path}/${log_file_name}.log ${cut_log_files_dir}/${log_file_name}_${date}.log ${nginx_sbin} -s reload gzip -c ${cut_log_files_dir}/${log_file_name}_${date}.log >${cut_log_files_dir}/${gzipFilename} #upload file to oss# /usr/bin/python /root/scripts/upload.py ${gzipFilename} ${ProjectName}}for log_file_name in ${logfilename_array[@]}do cut_gzip_upload ${log_file_name}done
一般备份:
#!/bin/bash##web-rsyncrsync -avz /data/wwwroot/web /data/backup/web##mysqldumpdate=`date +%F` backupdir=/data/backup/dbcd $backupdirmkdir $datecd $datemysqldump -uroot -p123456 ultrax >ultrax.sql #######delete backup file before 4days#######################/usr/bin/find ${backupdir} -ctime +6 | xargs rm -rf