Nginx automated /tmp cleanup?

2019-08-16 14:56发布

问题:

I've installed Nginx on my vps

i found this message inside Nginx Admin

To automated /tmp cleanup add bellow cron 
0 */1 * * * /usr/sbin/tmpwatch -am 1 /tmp/nginx_client
via crontab -e command

where i should execute this line ?

 0 */1 * * * /usr/sbin/tmpwatch -am 1 /tmp/nginx_client

my vps centos 5 32 cpanel

回答1:

Go to the console of your VPS and do the following:

 $ crontab -e

Then, in the cron file (which schedules jobs using the * * * * * syntax that you can read more about on Wikipedia) enter that line:

0 */1 * * * /usr/sbin/tmpwatch -am 1 /tmp/nginx_client

This will execute the command tmpwatch every hour, on the hour.

tmpwatch will remove all files with a modified file time greater than 1 hour in the /tmp/nginx_client directory.



回答2:

another way...

0 * * * * find /tmp/nginx_client/ -type f -mtime +8 -delete > /dev/null 2>&1


标签: nginx