The service log fills the server disk frequently, and if you do not clean it, the service may not work correctly. Appropriately increase the print level of the log, such as the info level to warn can be temporarily mitigated, but not long,
You have to write a script to clean it up regularly.
#!/bin/bash#clearlog.shnginxdir=/usr/local/nginx/logs/*devinfo= ($ (df-l | awk ' {print $} ')) #日志所处的磁盘perInfo = ($ (df-l | awk ' {print int ($)} ')) #磁盘使用率for i in ' seq 0 ${#perInfo [@]} ';d o if [[${devinfo[i]} = '/dev/xvda1 '] && [[${perinfo[i]}-ge 80]];< C2/>then for file in $nginxDir; Do exist= ' echo $file | awk ' {if (match ($0,/\.log/)) print "Yes"} "; if [[-F $file]] && [[${exist} = yes]]; Then echo ' > $file; echo $ (date) $file "Clear log ok!" >>/var/log/clear.log; fi; Done fi; Done
Determine the use of the log disk, the general usage rate of 80% can be cleaned up.
Then start a timed task:
Crontab-e
Input:
0/30 * * * */xxx/clearlog.sh
Detect disk usage every 30 minutes
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Linux Log timed Cleanup script