Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

tmpwatch help

Discussion in 'General Discussion' started by johnchristy, Mar 7, 2014.

  1. johnchristy

    johnchristy Active Member

    Joined:
    Mar 7, 2014
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    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
     
  2. ITGabs

    ITGabs Well-Known Member

    Joined:
    Jul 30, 2013
    Messages:
    81
    Likes Received:
    0
    Trophy Points:
    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:
    root@tulkas [/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>
    root@tulkas [/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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. johnchristy

    johnchristy Active Member

    Joined:
    Mar 7, 2014
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    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?
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,711
    Likes Received:
    1,791
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. johnchristy

    johnchristy Active Member

    Joined:
    Mar 7, 2014
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hello Michael,

    Thank you very much for this guide. I have edited /var/spool/cron/root will post the result within 24-48hrs

    Thanks
     
  6. johnchristy

    johnchristy Active Member

    Joined:
    Mar 7, 2014
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Works great. Now my tmp folders are clean.

    Thanks Michael :)
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,711
    Likes Received:
    1,791
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    I am happy to see the issue is now resolved. Thank you for updating us with the outcome.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice