日誌瘋狂增長,咋整呢,磁碟達到一定比例,重啟服務,刪除日誌....
~ ]# cat disk_use_info.sh
#!/bin/bash
DISK_USAGE=$(df -h --output=pcent / | tail -n +2 |cut -d'%' -f1)
if [[ $(awk '{if ($1>80) print 1; else print 0}' <<< "$DISK_USAGE") -eq 1 ]]; then
echo $(date +%F" "%T) $DISK_USAGE >> /root/disk_use_log
/zw56/monitor/sbin/restart.sh zw56-vgs-monitor-server-1.0.jar
else
echo $(date +%F" "%T) $DISK_USAGE >> /root/disk_use_log
fi
結合系統定時任務
[root@monitor ~]# crontab -l
# 日誌處理
0 * * * * /usr/local/share/disk_use_info.sh