日志切割
#!/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
时间: 2024-10-06 04:40:33