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!

Cronjob to remove a file

Discussion in 'General Discussion' started by Akyla, Feb 10, 2012.

  1. Akyla

    Akyla Registered

    Joined:
    Feb 10, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    51
    cPanel Access Level:
    Root Administrator
    Hello I need to create a cronjob to remove a file every day.

    this is what i have so far


    30 16 * * * rm /home/tndatls/public_html/error_log.txt


    any ideas?
     
  2. jgillmanjr

    jgillmanjr Active Member
    PartnerNOC

    Joined:
    Feb 9, 2012
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    51
    Location:
    Lansing, MI
    cPanel Access Level:
    DataCenter Provider
    Akyla,

    That looks like it should work for removing the file at 1630 hours every day.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Akyla

    Akyla Registered

    Joined:
    Feb 10, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    51
    cPanel Access Level:
    Root Administrator
    I just notice it :), but i found the real problem here the file that I need to remove is

    Type: text/x-generic

    I dont know if *.txt should work as extension for this, any sugestions?, also the Permission is 0644
     
    #3 Akyla, Feb 10, 2012
    Last edited: Feb 10, 2012
  4. jgillmanjr

    jgillmanjr Active Member
    PartnerNOC

    Joined:
    Feb 9, 2012
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    51
    Location:
    Lansing, MI
    cPanel Access Level:
    DataCenter Provider
    Akyla,

    You would specify the actual name of the file. Usually it wouldn't have an extension of .txt - so the file would most likely be /home/tndatls/public_html/error_log

    What user are you running the cronjob as? The one that owns the file, root, or another?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Akyla

    Akyla Registered

    Joined:
    Feb 10, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    51
    cPanel Access Level:
    Root Administrator
    The one that owns the file, this is the message with and without extension

    rm: cannot remove `/home/tndatls/public_html/error_log.txt': No such file or directory

    rm: cannot remove `/home/tndatls/public_html/error_log': No such file or directory
     
  6. jgillmanjr

    jgillmanjr Active Member
    PartnerNOC

    Joined:
    Feb 9, 2012
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    51
    Location:
    Lansing, MI
    cPanel Access Level:
    DataCenter Provider
    Akyla,

    Is the file still there, or has it been deleted already?

    Additionally, I would probably advise against deleting log files unless they got enormously large (for trouble shooting reasons down the road should they be needed).
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. Akyla

    Akyla Registered

    Joined:
    Feb 10, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    51
    cPanel Access Level:
    Root Administrator
    Its gone now took a while to show up the result, and we need to remove it cos we are working on figure it out how to solve the problem. :P

    Thank you so much for your help.
     
  8. jgillmanjr

    jgillmanjr Active Member
    PartnerNOC

    Joined:
    Feb 9, 2012
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    51
    Location:
    Lansing, MI
    cPanel Access Level:
    DataCenter Provider
    Glad I could help!
     
    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