Linux tmpwatch Command

Linux 命令大全Linux Command Reference

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, measured in hours.

Syntax

tmpwatch [-afqv][--test][超期时间][目录...]

Parameters:

  • -a or --all: Delete any type of file.
  • -f or --force: Force delete files or directories, similar to the "-f" parameter 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: Only for testing, does not actually delete files or directories.

Examples

Use the command "tmpwatch" to delete files in the directory "/tmp" that have not been used for more than one day. Enter the following command:

$ tmpwatch 24 /tmp/ #删除/tmp目录中超过一天未使用的文件

After executing the above command, the execution 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 the tmpwatch command. The operation to switch to administrative privileges is as follows:

$ su                                #切换到root用户  
口令:**********                   #输入用户密码  

Linux 命令大全Linux Command Reference

Other Extensions