The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Setting up cron as root

Discussion in 'General Discussion' started by GoWilkes, Jan 25, 2016.

  1. GoWilkes

    GoWilkes Well-Known Member

    Joined:
    Sep 26, 2006
    Messages:
    367
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    It's been awhile since I had to do this, so I hope you guys don't mind holding my hand :)

    I have a weird log file in the /tmp directory, named Net.WhoisIP.log. I gather that it's related to the Net::Whois Perl module that I use, but I can't find a way to turn off the log! When I looked earlier today, the log file was around 2G.

    I don't know if deleting it will impact the module, so I figured I would just empty it through a cron every month.

    IIRC, this needs to be done by manually editing /etc/crontab.

    Assuming that's correct, does this look right?

    Code:
    59 1 31 * * root > /tmp/Net.WhoisIP.log
    
    I'm trying to make it run at 1:59am on the 31st of the month, which presumably means it would run every other month.

    Note that there's a single whitespace separating everything, including the "> /tmp/..." command. Is that correct? I ask because it looks weird, like the last space would be a confusing delimiter, which makes me worry that I'll accidentally truncate every file in /root/! LOL

    TIA!
     
  2. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,146
    Likes Received:
    34
    Trophy Points:
    48
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hello :)

    Yes, You have setup correct cron.

    Code:
    59 1 31 * * root > /tmp/Net.WhoisIP.log 
    If you this cron on your server then it will be run at :

    2016-01-31 01:59:00
    2016-03-31 01:59:00
    2016-05-31 01:59:00
    2016-07-31 01:59:00
    2016-08-31 01:59:00
    ....
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    You may want to configure a script that completes the removal so that you configure the cron job like this:

    Code:
    59 1 31 * * /path/to/removal-script.sh
    Thank you.
     
Loading...

Share This Page