当前位置: 首页 > linux > 正文

Linux will keep /tmp files for 10 days by default

For files in /tmp directory, linux has cron at /etc/cron.daily to deal with:
[2hei.net cron.daily]$ cat tmpwatch
flags=-umc
/usr/sbin/tmpwatch “$flags” -x /tmp/.X11-unix -x /tmp/.XIM-unix \
    -x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix 240 /tmp
/usr/sbin/tmpwatch “$flags” 720 /var/tmp
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
    if [ -d “$d” ]; then
    /usr/sbin/tmpwatch “$flags” -f 720 “$d”
    fi
done

Linux will keep 10 days files in /tmp and 30 days in /var/tmp by default.

[2hei.net cron.daily]$ man tmpwatch
NAME
       tmpwatch – removes files which haven?. been accessed for a period of time

SYNOPSIS
       tmpwatch [-u|-m|-c] [-MUadfqstvx] [–verbose] [–force] [–all]
                      [–nodirs] [–nosymlinks] [–test] [–fuser] [–quiet]
                      [–atime|–mtime|–ctime] [–dirmtime] [–exclude <path>]
                      [–exclude-user <user>] <hours> <dirs>
OPTIONS
       -u, –atime
              Make the decision about deleting a file based on the file?. atime (access time). This is the default.

              Note that the periodic updatedb file system scans keep the atime of directories recent.

       -m, –mtime
              Make the decision about deleting a file based on the file?. mtime (modification time) instead of the atime.

       -c, –ctime
              Make the decision about deleting a file based on the file?. 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?. 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.

       -d, –nodirs
              Do not attempt to remove directories, even if they are empty.

       -d, –nosymlinks
              Do not attempt to remove symbolic links.

       -f, –force
              Remove files even if root doesn?. have write access (akin to rm -f).

       -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 on fuser being installed in /sbin.  Not
              supported on HP-UX or Solaris.

       -t, –test
              Don?. remove files, but go through the motions of removing them. This implies -v.

       -U, –exclude-user=user
              Don?. 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.

本文固定链接: https://www.2hei.net/2011/08/03/linux_will_keep_tmp_files_for_10_days_by_default/ | 2hei.net

该日志由 u2 于2011年08月03日发表在 linux 分类下,
原创文章转载请注明: Linux will keep /tmp files for 10 days by default | 2hei.net
关键字:

报歉!评论已关闭.