davood

Active Member
Aug 29, 2004
25
0
151
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
 

bijo

Well-Known Member
Aug 21, 2004
474
0
166
India

davood

Active Member
Aug 29, 2004
25
0
151
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.
 

davood

Active Member
Aug 29, 2004
25
0
151
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
 

davood

Active Member
Aug 29, 2004
25
0
151
sawbuck said:
Must be missing your intent as logrotate runs as a daily cronjob.
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.
 

sawbuck

Well-Known Member
Jan 18, 2004
1,365
10
168
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}
 

davood

Active Member
Aug 29, 2004
25
0
151
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..
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,437
33
473
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.
 

davood

Active Member
Aug 29, 2004
25
0
151
chirpy said:
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.
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.
 

Website Rob

Well-Known Member
Mar 23, 2002
1,501
1
318
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.
 

davood

Active Member
Aug 29, 2004
25
0
151
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
 

sawbuck

Well-Known Member
Jan 18, 2004
1,365
10
168
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.
 

craig1972

Member
Apr 3, 2005
15
0
151
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,

* 1 * * * cp /dev/null /home/davood/public_html/error_log
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.
 

davood

Active Member
Aug 29, 2004
25
0
151
that does help... now what i need to know is what is the path the the error logs???
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,437
33
473
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.
 

davood

Active Member
Aug 29, 2004
25
0
151
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
 

davood

Active Member
Aug 29, 2004
25
0
151
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