confused about use of logrotate and cron.daily
Hi,
Recently I saw that my syslog and daemon.log files in /var/log directory are huge (7G each). They were eating up all the diskspace in my / directory. So to save some space I truncated the daemon.log using the truncate command and restarted the laptop. There were a lot of errors while shutting down but eventually things became normal. So far so good. Now I was looking about limiting size of logfiles. And found that I can use logrotate as a cron job to do so (http://www.thegeekstuff.com/2010/07/logrotate-examples/) As per the guide, I poked around in my configurations. Here is how things look: Code:
somesh@creativision:/etc/logrotate.d$ crontab -l Code:
somesh@creativision:/etc/logrotate.d$ cd /etc/cron.daily/ Code:
somesh@creativision:/etc/cron.daily$ cat logrotate Code:
somesh@creativision:/etc/logrotate.d$ cat /etc/logrotate.conf Code:
somesh@creativision:/etc/logrotate.d$ ll Code:
somesh@creativision:/etc/logrotate.d$ cat rsyslog 1. As far as I know, even if my list of crontab (crontab -l) shows nothing, the files under cron.daily directory work as a daily cronjob. Is that right? 2. Is the daily cron of logrotate looking into all the files in logrotate.d directory ("include /etc/logrotate.d" line in logrotate.conf) and rotating the logs accordingly? Or is it just rotating wtmp and btmp? 3. It seems to me that if I add a line "size 1000000k" in the rsyslog file in logrotate.d, the size of these log files will be limited to 1G. Now will that hamper the performance of my laptop any way? TIA, |
1. The cron.daily files will be run by root - if you type the 'crontab -l' command as super-user, you should see that a script is run daily that executes the cron.daily files.
2. logrotate uses all the files in the logrotate.d directory, as a consequence of the include line. 3. You could use "size 1000000k" instead of "daily", to rotate when the file gets too big instead of daily - this shouldn't impact the laptop performance. The real issue is why syslog isn't being rotated daily, since that is what should be happening with this configuration. Do you turn off your laptop nightly? If so, check the output from the 'crontab -l' to see when the cron.daily files are being run. You may need to edit the crontab to get them run at a time that the laptop is on. |
Quote:
The crontab list for super-user also seems to be empty Code:
somesh@creativision:~$ sudo crontab -l On the last note: Yes, I do turn off or put it to sleep nightly. So if the cron job is set to run late at night, it may not be able to logrotate at all. But I cannot find any time schedule for the cron.daily jobs. TIA |
You are probably running a version of cron (e.g. "Vixie Cron") that has a system-wide config file '/etc/crontab' - the times for cron.daily etc. will be there. You can, as root, simply edit this file - you don't need to use 'crontab -e'.
If you can't choose a time of day when your laptop will always be on, you could move the logrotate file from cron.daily to cron.hourly. This would run logrotate hourly, but it would still rotate files according to its configuration (daily, weekly, by size, ...). |
You can also check out anacron, which runs any crons that should have run by the time anacron is started.
|
All times are GMT -5. The time now is 02:40 AM. |