Portal Home > Knowledgebase > Articles Database > Rotating Apache domlogs for 7 days?


Rotating Apache domlogs for 7 days?




Posted by thewird, 08-23-2007, 01:42 AM
Is there any way to rotate apache domlog files but only keep them for 7 days? thewird

Posted by sprintserve, 08-23-2007, 03:56 AM
Do you run any control panels? If you do run for example Cpanel, you would first need to disable the deletion of logs after each stats run. You would also need to create a new logrotate script alone the lines of: Use at your own risk. You may also want to remove compress if you do not want to compress the logs which can be cpu intensive if you have large logs.

Posted by thewird, 08-23-2007, 08:04 AM
Using cpanel and yes I know I have to disable the deletion of logs after stats run. I wanted a way to keep logs for 7 days. Will this script delete the current domlog and create a backup file and delete it after 7 days (running it as a cron every 6 hours or so). The reason the domlog must be deleted is so it doesn't grow over 2GB where apache stops working. Thanks. thewird

Posted by sprintserve, 08-23-2007, 08:27 AM
That's what it does.

Posted by thewird, 08-23-2007, 08:55 AM
When I run it it gives permission denied and commmand not found... File is owned by root and chmodded to 755. System OS is Fedora Core 5 thewird

Posted by sprintserve, 08-23-2007, 01:15 PM
It's meant for logrotate. Create a new file in /etc/logrotate.d/. Name it httpd or apache etc and run logrotate.

Posted by thewird, 08-23-2007, 01:47 PM
Nowthing happened when I ran "logrotate /etc/logrotate.d/rotatedomlogs.txt" The log files are still in domlogs. Maybe I need to specify where it stores the logs? thewird

Posted by thewird, 08-24-2007, 01:41 AM
bump. thewird

Posted by sleddog, 08-24-2007, 05:58 AM
Read the man page for logrotate -- 'man logrotate'. You could add the -v or -d switch for more verbose output when testing it at the command line, or the -f switch to force logrotate to do the rotations even if it 'thinks' it's not necessary.

Posted by thewird, 08-24-2007, 11:09 AM
Thank you, it works. Does logrotate run automatically or do I need to run a cron? thewird

Posted by sleddog, 08-24-2007, 04:34 PM
Logrotate is run automatically. You'll probably find a script for it at /etc/cron.daily/logrotate

Posted by sirius, 08-24-2007, 04:36 PM
Moved to Technical and Security Issues.... Sirius



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
webunited? (Views: 550)