The system log is a very important thing but at the same time if we do not regularly clear the space will be to the log, I would like to introduce a regular delete log implementation methods, you can refer to the students.
Nginx's log files accumulate too much and finally fill up the entire disk space, so yesterday a script that can be automatically deleted on a regular basis.
#!/bin/bash
find/usr/local/nginx/logs/-mtime +15-type f-name *.log | Xargs rm-f
The above script is to delete the log files from the 15 days before nginxlogs, and you can refer to the above script to delete the log files of other programs, such as PHP and Tomcat. However, the use of the script will need to nginx log files to automatically split, otherwise it will delete the log file is being written, Nginx log segmentation script can see the Linux source mode installation nginx and PHP (FastCGI) or CentOS system initial installation MySQL, PHP and Nginx scripts.
To save the script and use the chmod +x command to specify executable permissions, it is best to join the task list (performed one o'clock in the morning every day):
[Root@localhost ~]# crontab-e * *
/bin/bash/root/shell/autodellogs.sh
[root@localhost ~]# service Crond Restart