且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Nginx 自动/tmp 清理?

更新时间:2022-06-15 08:42:46

转到 VPS 的控制台并执行以下操作:

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

 $ crontab -e

然后,在 cron 文件中(使用 * * * * * 语法安排作业,您可以阅读有关 ***上)输入该行:

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

这将每小时执行一次 tmpwatch 命令.

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

tmpwatch 将删除 /tmp/nginx_client 目录中所有修改文件时间超过 1 小时的文件.

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