日志切割
#!/bin/bash #cut nginx logs nginx_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 reload function 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-rsync rsync -avz /data/wwwroot/web /data/backup/web ##mysqldump date=`date +%F` backupdir=/data/backup/db cd $backupdir mkdir $date cd $date mysqldump -uroot -p123456 ultrax >ultrax.sql #######delete backup file before 4days####################### /usr/bin/find ${backupdir} -ctime +6 | xargs rm -rf
本文出自 “记录点滴” 博客,请务必保留此出处http://caozm.blog.51cto.com/1118764/1618927
原文地址:http://caozm.blog.51cto.com/1118764/1618927