Linux 日誌清理(anbile+rsync+crontab)
阿新 • • 發佈:2018-12-28
1#清理日誌指令碼 log="/tmp/back.log" cleardate=`date "+%Y%m%d%H%M%S"` for i in `find /software/* -name "catalina.out" -o -name "*.log" ! -user root`;do cat /dev/null>$i;done; echo > /weblogic/user_projects/domains/sssl_domain/logs/sssSvr5401.log; echo "清理日誌定時任務記錄: $cleardate" >>$log 2#rsync同步清理日誌指令碼到所有的微服務應用下 #######釋出應用 ########################釋出國稅外網######################## #開始發步到tomcat-cjpt-17 rsync -rp /software/autoClearLogs.sh -e "ssh -p2222"
[email protected]:/software/ #3ansible執行清理日誌指令碼 #!/bin/sh #######清理日誌服務 ##################清理日誌外網################## ansible wan_cjpt -m shell -a "/software/autoClearLogs.sh" ansible wan_xxmh -m shell -a "/software/autoClearLogs.sh" ##################清理日誌內網國稅################## ansible lan_hxfw -m shell -a "/software/autoClearLogs.sh" ansible lan_sbzs_gs -m shell -a "/software/autoClearLogs.sh" ansible lan_sxsl_gs -m shell -a "/software/autoClearLogs.sh" ansible lan_job_gs -m shell -a "/software/autoClearLogs.sh" ansible lan_job_ds -m shell -a "/software/autoClearLogs.sh" ansible lan_job_gs_swry -m shell -a "/software/autoClearLogs.sh" ##################清理日誌內網地稅################## ansible lan_sbzs_ds -m shell -a "/software/autoClearLogs.sh" ##################清理日誌地稅內網################## ansible lan_sxsl_ds -m shell -a "/software/autoClearLogs.sh" ansible lan_job_ds_swry -m shell -a "/software/autoClearLogs.sh" ansible lan_job_ds_swry -m shell -a "/software/autoClearLogs.sh" #4定時任務執行ansible指令碼(3) 30 23 * * * /bin/bash /software/ansible2clearLog.sh >/dev/null 2>&1 30 10 * * * /weblogic/user_projects/domains/sssl_domain/clearAlllogs.sh >/dev/null 2>&1