Linux tmpwatch command
The Linux tmpwatch command is used to delete temporary files.
Executing the tmpwatch command can delete unnecessary temporary files. You can set the file expiration time in hours.
Syntax
tmpwatch [-afqv][--test][超期时间][目录...]
Parameters:
- -a or --all Delete files of any type.
- -f or --force Force deletion of files or directories, similar to the "-f" option of the rm command.
- -q or --quiet Do not display the command execution process.
- -v or --verbose Display the command execution process in detail.
- -test For testing only; it does not actually delete files or directories.
Example
To use the "tmpwatch" command to delete files in the "/tmp" directory that have not been used for more than a day, enter the following command:
$ tmpwatch 24 /tmp/ #删除/tmp目录中超过一天未使用的文件
After the above command is executed, the result is as follows:
removing directctmp/orbit-tom if not empty
Note: This command requires root privileges, so you should use the su command to switch users before using tmpwatch. The operation to switch administrative privileges is as follows:
$ su #切换到root用户
口令:********** #输入用户密码
Linux Command Reference