2 Steps for Scheduled cleanup
1. Find out the files that need to be cleaned
2, the system to increase the scheduled execution of tasks
First step , VI dellog.sh
Step Two , find the files you need to clean up
Input: Find/var/log/nginx-mtime +7-type f-name \*.log | Xargs rm-f
which
-mtime +7 to find files 7 days ago
Http://blog.sina.com.cn/s/blog_716358dc0100lj5p.html
-type F, type is file
Http://zhidao.baidu.com/link?url=KH_ Fs6kqvwbcfsxfvha2cxi-193wbkztamsvr-gmgfvc7s-8ldpndpcjk6uzj6hzxcc47nwku7rcp7datxvsvuf6z19rn18cerla5dgi9-c
-name \*.log, locate the. Log end file in the current directory
Xargs rm-f, execute the Delete command
http://czmmiao.iteye.com/blog/1949225
Step three , start a scheduled task under Linux and add the two shell scripts you just created to the program
VI root//based on the user name logged in at this time, for example, I am logged in at this time is the root user, enter the following content
0 0 * * */var/log/nginx/dellog.sh
After saving, exit, enter command Crontab root will see the/var/spool/cron/folder under the corresponding copy file root. This completes the Nginx log by day split with regular cleanup.
Http://www.cnblogs.com/peida/archive/2013/01/08/2850483.html
Reference: http://jingyan.baidu.com/article/86112f135151412736978762.html
linux-implementing scheduled cleanup of logs