johnchristy

Active Member
Mar 7, 2014
28
0
1
cPanel Access Level
Root Administrator
hi

I'm using a VPS with CentOS release 5.10 (Final)

When I SSH with vi /etc/cron.daily/tmpwatch it shows :

===
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 \
-X '/tmp/hsperfdata_*' 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
~
~
===

What I want is /tmp folder to be auto cleared every 24hrs automatically. Would really appreciate if anyone can tell me the exact changes I need to make to this above script

Thanks
John
 

ITGabs

Well-Known Member
Jul 30, 2013
81
0
6
cPanel Access Level
Root Administrator
Hi John,

I think is better that you use the tmpwatch command directly, I never edited that file manually but I see that there are some variables $flags and $d so if you edit that cron manually you will get in trouble probably

I am using Centos 6.x but tmpwatch should be exactly the same that in 5.x
Code:
[email protected] [/home/securwp]# tmpwatch
tmpwatch 2.9.16 - (C) 1997-2009 Red Hat, Inc. All rights reserved.
This program may be freely redistributed under the terms of the
GNU General Public License version 2.

tmpwatch [-u|-m|-c] [-MUadfqtvx] [--verbose] [--force] [--all] [--nodirs] [--nosymlinks] [--test] [--quiet] [--atime|--mtime|--ctime] [--dirmtime] [--exclude <path>] [--exclude-user <user>] <hours-untouched> <dirs>
[email protected] [/home/securwp]#
The following code will remove all files from /tmp if they are not accessed in the latest 24 hours

Code:
tmpwatch --mtime --all 336 /tmp
-Gabriel
 

johnchristy

Active Member
Mar 7, 2014
28
0
1
cPanel Access Level
Root Administrator
Hi John,

I think is better that you use the tmpwatch command directly, I never edited that file manually but I see that there are some variables $flags and $d so if you edit that cron manually you will get in trouble probably

I am using Centos 6.x but tmpwatch should be exactly the same that in 5.x
Code:
[email protected] [/home/securwp]# tmpwatch
tmpwatch 2.9.16 - (C) 1997-2009 Red Hat, Inc. All rights reserved.
This program may be freely redistributed under the terms of the
GNU General Public License version 2.

tmpwatch [-u|-m|-c] [-MUadfqtvx] [--verbose] [--force] [--all] [--nodirs] [--nosymlinks] [--test] [--quiet] [--atime|--mtime|--ctime] [--dirmtime] [--exclude <path>] [--exclude-user <user>] <hours-untouched> <dirs>
[email protected] [/home/securwp]#
The following code will remove all files from /tmp if they are not accessed in the latest 24 hours

Code:
tmpwatch --mtime --all 336 /tmp
-Gabriel
Thank you for the comment Gabriel, but it seems like the files are different and I'm not quite sure what is the meaning of the timing involved here. From the code I pasted do you know where it defines a timeframe? for example after 24hrs these files will be removed?