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.

Comments in crontab disappear

Discussion in 'General Discussion' started by LGferion, May 31, 2008.

  1. LGferion

    LGferion Registered

    Joined:
    May 31, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I do not know for certain that cPanel/WHM is causing my current problem, but I believe that it may be associated.

    I have a very long crontab file under my root user, and so have elected to add comment blocks to seperate critical features to better organize myself. I also occasionally comment out lines, rather than remove them completely, that I do not want to execute for one reason or another.

    On my old server, which did not have cpanel/whm installed this worked perfectly. But now we have a new server with cpanel/whm installed, and it appears to cause the comment lines (including features I just wanted to temporarily disable) to completely disappear from crontab -l and -e. This does not happen immediately (ie I can do a crontab -e, add comments at will and install the file using vim...crontab -l shows my comments for at least 30 minutes afterward), but probably once a day, or perhaps when someone else (I'm not the only admin) accesses cron from within cpanel rather than via shell. So...what cPanel script (either cron based or webaccess based) ignores commented (#) lines and re-writes the rest to the crontab as root, blank lines included? How can this be fixed?
     
  2. Chris B

    Chris B Member

    Joined:
    Nov 26, 2001
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    England
    This line in /usr/local/cpanel/bin/edcron seems to be responsible for removing the comment:

    Code:
    crontab=`crontab -l | grep -v "^#"`
    I'm not sure if that's the right script that's called in cPanel, or if edcron is called for other uses, but that might be a good place to begin your suspicions. Also, the above script only matches lines beginning with "#", so a workaround might be to use " #" as the comment. For example:

    Code:
    # Upgrade cPanel <-- removed
    1 0 * * * /scripts/upcp
     # Backup cPanel <-- not removed, has a space in front of it
    0 1 * * * /scripts/cpbackup
    I haven't tried that with cPanel itself, but it's maybe worth a shot.
     
  3. LGferion

    LGferion Registered

    Joined:
    May 31, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    modified

    I've modified the line to not grep at all. I'll let you know how that goes for me. Thanks for your help!
     
    #3 LGferion, Jun 4, 2008
    Last edited: Jun 4, 2008
  4. LGferion

    LGferion Registered

    Joined:
    May 31, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    well... my solution doesn't work, because edcron re-installed its default conformation overnight, which then resulted in wiping the comments again from my tab. I'll try the " #" within my tab itself now, as originally suggested.

    Although, what would happen if I chmod'd edcron to 555? could I chmod back to 755 if I wanted to edit it later?
     
  5. LGferion

    LGferion Registered

    Joined:
    May 31, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    For future reference: the suggested method has been stable now for a couple of weeks.

    Place a space before your #comments
     
  6. forlinuxsupport

    forlinuxsupport Well-Known Member
    PartnerNOC

    Joined:
    Dec 22, 2004
    Messages:
    386
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    thanks, I will try that.

    this one has been bugging me for years !! :)
     
Loading...

Share This Page