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.

error logs and cron jobs

Discussion in 'General Discussion' started by davood, May 25, 2005.

  1. davood

    davood Active Member

    Joined:
    Aug 29, 2004
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    Hi there,
    i am curious to know if anyone knows of a cron job command i can use to have my error log cleared out every so often...

    any help would me much appreciated... thanks in advance.
    -Davood
     
  2. bijo

    bijo Well-Known Member

    Joined:
    Aug 21, 2004
    Messages:
    475
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
  3. davood

    davood Active Member

    Joined:
    Aug 29, 2004
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    thank you for the links, but they did not tell me what cron job i would need to use in order to clean out the error logs automatically every so often.

    thnx.
     
  4. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
  5. davood

    davood Active Member

    Joined:
    Aug 29, 2004
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    again.. thanks... but i want to do it using cron jobs.. that is just a walk through of how to do it by editing files.

    thx again for the time. and thanks in advance for any future help
     
  6. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Must be missing your intent as logrotate runs as a daily cronjob.
     
  7. davood

    davood Active Member

    Joined:
    Aug 29, 2004
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    ok... well what i am asking for is the command i have to enter into cron tab.. the last link you provided is telling me to edit files...

    thx agian.
     
  8. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    k. One last try.

    The cron command that logrotate uses is: /usr/sbin/logrotate /etc/logrotate.conf. Of course this presumes a logrotate.conf file which is referenced in the previous link.

    Other possible may be to use something like cat /dev/null > {filename}
     
  9. davood

    davood Active Member

    Joined:
    Aug 29, 2004
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    I am just confused..
    I will look into this more this weekend and read those sites you provided again...

    thx for the help... if I am still confused after reading the sites again... i will post here for help..
     
  10. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    The link that sawbuck gave to you details all you need to do to have your logs rotated. There's an application that runs on your server called logrotate exactly for that function which already runs in cron every day or week, depending on your server setup. Adding an additional crontab to run it separately won't make much difference for that reason and is probably a bad idea as it defeats the object of running logrotate in the first place.
     
  11. davood

    davood Active Member

    Joined:
    Aug 29, 2004
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    thanks.. but for some reason mine does not rotate until there have been 500 errors... and all that happends is on the 501st it simply pushes the oldest one out...

    what i am trying to do is completely clean it out after about 100 errors.

    Thanks.
     
  12. Website Rob

    Website Rob Well-Known Member

    Joined:
    Mar 23, 2002
    Messages:
    1,506
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    Alberta, Canada
    cPanel Access Level:
    Root Administrator
    davood, you are getting hung-up on syntax, for what you want to do.

    Cron jobs / logrotate all work on "time" and not "amount". As you can setup to run a specific logrotate -- a Cron job itself -- on a "daily" basis, it wouldn't matter how many errors there are.
     
  13. davood

    davood Active Member

    Joined:
    Aug 29, 2004
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    ok.. you guys are all completely misunderstanding what I want to do...
    I want the error log to be cleared more often then it is currently being cleared...

    any help would be apreciated...and thanks in advance
     
  14. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    So if it is currently be cleared (rotated) by a daily cron job then simply move the logrotate cron to /etc/cron.hourly and execute it that way.
     
  15. craig1972

    craig1972 Member

    Joined:
    Apr 3, 2005
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    davood,

    For emptying a file, you can do "cp /dev/null /path/to/file".

    So for instance if your error_log is in the public_html folder, you can have this in your cron for instance,

    This will automatically empty your error_log file every day at 1 o'clock.

    I would recommend however that you fix whatever is causing all those 501s first.

    Hope this helps.
     
  16. davood

    davood Active Member

    Joined:
    Aug 29, 2004
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    that does help... now what i need to know is what is the path the the error logs???
     
  17. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    You need to do a bit more than copying null into it. You also have to restart apache afterwards as the original file and its space allocation will remoain until you do so on disk.
     
  18. davood

    davood Active Member

    Joined:
    Aug 29, 2004
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    i know this too... but i still need to know where the file can be found that i need to remove...

    thanks in advance fro the help
     
  19. davood

    davood Active Member

    Joined:
    Aug 29, 2004
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    i am asking where the server log for the whole server is.. not only my account...

    i own the server and want to clean everyones error log not only mine
     
Loading...

Share This Page