English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux tmpwatch command

Linux 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 expiry time, which is calculated in hours.

Syntax

tmpwatch [-afqv][--test][Expiry Time][Directory...]

Parameters:

  • -a or--all  Deletes any type of file.
  • -f or--force  Forces the deletion of files or directories, similar to the effect of the rm command's "-f parameter.
  • -q or--quiet  Does not display the command execution process.
  • -v or--verbose  Displays detailed information about the command execution process.
  • -test  Used for testing only, it does not really delete files or directories.

Online Examples

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

$ tmpwatch 24 /tmp/ #Delete/Files in the tmp directory that have not been used for more than one day

After executing the above commands, the results are 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 management privileges is as follows:

$ su                                #Switch to root user  
Password:**********                   #Enter user password  

Linux Command大全