您好,登錄后才能下訂單哦!
日志切割實例
1、任務計劃收切割和刪除日志的計劃
#tracking & cookiemapping #*/10 * * * * bash /usr/local/zamplus-luanx-server/bin/log_rotate.sh #5 0 * * * bash /usr/local/zamplus-luanx-server/bin/log_clean.sh
2、log_rotate.sh 切割日志,日志由nginx產生
root@TS02:/usr/local/LuanxServer/Luanx-shells# vim /usr/local/LuanxServer/Luanx-shells/log_rotate.sh #!/bin/bash _prefix="/usr/local/LuanxServer" _log_tracking_statistic_dir="/data/tracking/statistic" _log_cm_statistic_dir="/data/cm/statistic" if [ ! -d ${_log_tracking_statistic_dir} ]; then mkdir -p ${_log_tracking_statistic_dir}; fi if [ ! -d ${_log_cm_statistic_dir} ]; then mkdir -p ${_log_cm_statistic_dir}; fi time=`date +%Y%m%d%H%M` mv ${_prefix}/logs/tracking_site.log ${_log_tracking_statistic_dir}/track-s-${time}.log mv ${_prefix}/logs/tracking_promote.log ${_log_tracking_statistic_dir}/track-p-${time}.log mv ${_prefix}/logs/tracking_mob.log ${_log_tracking_statistic_dir}/track-m-${time}.log mv ${_prefix}/logs/tracking_conversion.log ${_log_tracking_statistic_dir}/track-c-${time}.log mv ${_prefix}/logs/cm.log ${_log_cm_statistic_dir}/cm-s-${time}.log kill -USR1 `cat ${_prefix}/logs/nginx.pid`
3、log_clean.sh 刪除超過15天的日志
root@02:/usr/local/LuanxServer/Luanx-shells# vim /usr/local/LuanxServer/Luanx-shells/log_clean.sh #!/bin/bash _log_tracking_statistic_dir="/data/tracking/statistic" _log_cm_statistic_dir="/data/cm/statistic" if [ ! -d ${_log_tracking_statistic_dir} ]; then exit; fi find ${_log_tracking_statistic_dir}/ -type f -mtime +15 -name "*.log" -exec rm -rf {} \; if [ ! -d ${_log_cm_statistic_dir} ]; then exit; fi find ${_log_cm_statistic_dir}/ -type f -mtime +15 -name "*.log" -exec rm -rf {} \;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。