TMPWATCH(8)
π TMPWATCH(8) π
okay bestie, listen up β this is the manual page for tmpwatch, living in the System Administrator's Manual section (section 8, we love a system-admin icon). Grab a boba, we're cleaning up /tmp together. π§Ήβ¨
β¨ NAME β¨
tmpwatch β removes files which haven't been accessed for a period of time π°οΈπ
πΈ SYNOPSIS πΈ
tmpwatch [-u|-m|-c] [-MUXadfqstvx] [--verbose] [--force] [--all]
[--nodirs] [--nosymlinks] [--test] [--fuser] [--quiet]
[--atime|--mtime|--ctime] [--dirmtime] [--exclude path]
[--exclude-user user] [--exclude-pattern pattern]
time dirs
π¦ DESCRIPTION π¦
So, tmpwatch recursively removes files that haven't been accessed for a given amount of time. Normally it's used to clean up directories that are just temporary holding space, like /tmp. It's giving janitor energy, but make it β¨automatedβ¨.
When it's changing directories, tmpwatch is super sensitive to possible race conditions and will exit with an error if it detects one. Heads up, it does not follow symbolic links in the directories it's cleaning (even if a symbolic link is handed to it as its argument), it does not switch filesystems (including non-trivial bind mounts), it skips lost+found directories owned by the root user, and it only removes empty directories, regular files, symbolic links, and β on some systems β unused sockets. That's the whole roster, no extras. π
By default, tmpwatch dates files by their atime (access time), not their mtime (modification time). So if files aren't being removed when ls -l is implying they totally should be, run ls -u to peek at their atime and see if that explains the whole situation. iykyk π
If the --atime, --ctime or --mtime options are used in combination, the decision about deleting a file gets based on the maximum of these times. And the --dirmtime option implies ignoring atime of directories, even if the --atime option is used. Teamwork makes the dream work, but like, competitively. π
The time parameter defines the threshold for removing files. If the file has not been accessed for time, the file is removed. The time argument is a number with an optional single-character suffix specifying the units: m for minutes, h for hours, d for days. If no suffix is specified, time is in hours. (default behavior slay π
)
Following this, one or more directories may be given for tmpwatch to clean up. π§Ό
π OPTIONS π
-u,--atimeβ Make the decision about deleting a file based on the file's atime (access time). This is the default. β
Note that the periodic updatedb file system scans keep the atime of directories recent. So like, don't be shocked bestie. π
-m,--mtimeβ Make the decision about deleting a file based on the file's mtime (modification time) instead of the atime. π-c,--ctimeβ Make the decision about deleting a file based on the file's ctime (inode change time) instead of the atime; for directories, make the decision based on the mtime. π-M,--dirmtimeβ Make the decision about deleting a directory based on the directory's mtime (modification time) instead of the atime; completely ignore atime for directories. π«π°οΈ-a,--allβ Remove all file types, not just regular files, symbolic links and directories. On systems wheretmpwatchcan remove unused sockets, make the decision only based on file times, ignoring possible use of the socket. π₯-d,--nodirsβ Do not attempt to remove directories, even if they are empty. π βοΈ-f,--forceβ Remove root-owned files even if root doesn't have write access (akin torm -f). πͺ-l,--nosymlinksβ Do not attempt to remove symbolic links. π«π-q,--quietβ Report only fatal errors. π€«-s,--fuserβ Attempt to use the"fuser"command to see if a file is already open before removing it. Not enabled by default. Does help in some circumstances, but not all. Dependent onfuserbeing installed in/sbin. Not supported on HP-UX or Solaris. π-t,--testβ Don't remove files, but go through the motions of removing them. This implies-v. π»-U,--exclude-user=userβ Don't remove files owned by user, which can be an user name or numeric user ID. π-v,--verboseβ Print a verbose display. Two levels of verboseness are available β use this option twice to get the most verbose output. π£οΈπ£οΈ-x,--exclude=pathβ Skip path; if path is a directory, all files contained in it are skipped too. If path does not exist, it must be an absolute path that contains no symbolic links. π-X,--exclude-pattern=patternβ Skip paths matching pattern; if a directory matches pattern, all files contained in it are skipped too. pattern must match an absolute path that contains no symbolic links. π§©
π SEE ALSO π
cron(1), ls(1), rm(1), fuser(1) β the squad, fr fr π«Ά
π AUTHORS π
- Erik Troan
<ewt@redhat.com> - Preston Brown
<pbrown@redhat.com> - Nalin Dahyabhai
<nalin@redhat.com> - Miloslav Trmac
<mitr@redhat.com>
absolute legends, no cap π
okay that's the whole page bestie!! πΈ This iconic piece of documentation is brought to you by the 4th Berkeley Distribution, dated 2009-10-15, and it's the TMPWATCH(8) page β go forth and clean your temp dirs, main character. πβ¨π¦
π¦ where this page comes from
- centos-stream 10: tmpwatch 2.11-28.el10 Β· GPL-2.0-only
- centos-stream 9: tmpwatch 2.11-20.el9 Β· GPLv2
- fedora 43: tmpwatch 2.11-29.fc43 Β· GPL-2.0-only
- fedora 44: tmpwatch 2.11-30.fc44 Β· GPL-2.0-only
- nixos 26.05: tmpwatch 2.11
- nixpkgs unstable: tmpwatch 2.11
- opensuse-leap 16.0: tmpwatch 2.11-bp160.1.12 Β· GPL-2.0-only
- opensuse-leap 16.0: tmpwatch 2.11-bp160.1.12 Β· GPL-2.0-only
- opensuse-leap 16.0: tmpwatch 2.11-bp160.1.12 Β· GPL-2.0-only
- opensuse-leap 16.0: tmpwatch 2.11-bp160.1.12 Β· GPL-2.0-only
- Copyright (C) 1997-2001, 2004-2009 Red Hat, Inc. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms