Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
My server does seem to be rotating my daily logs at 0730 each morning. Is this where I would change the time for this? How would I do this using the safety of crontab for #/etc/cron.d/anacron?
Could I execute this manually to force a log rotation without ending up with two rotations:
test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null
Assuming this is on Debian 7 Wheezy, logrotate is run by /etc/cron.daily/logrotate. On a system with anacron installed, all the /etc/cron.daily/* scripts are run in lexical order by run-parts as scheduled by /etc/crontab. The default /etc/crontab:
Code:
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
The actual time that the /etc/cron.daily/logrotate script starts depends on how long previous corn.daily scripts take to run.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
Now what do I need to change the times in one or both of these files to change the daily logrotate to 20:30 my local time? Right now it seems to be rotating around 07:45 to 08:00.
First disable the existing /etc/cron.daily/logrotate. A nice way to do so is to rename it as /etc/cron.daily/logrotate.disabled. That way it is easy to restore it if and when you want and clear that it has been disabled.
Then set up a scheduled job to replace it. Three options:
/etc/crontab
root's crontab
An /etc/cron.d file
AFAIK "the Debian way" is to use root's crontab (/etc/crontab is installed by package so best not changed and IIRC /etc/cron.d is intended for packages, not sysadmins to create files in).
As root, use the crontab -e command (taking care not to key r instead of e!) and create a line:
What is really strange about this is one of my daily file date/tine rotated at 'Tue Aug 26 07:27:34 CDT 2014'. Not 30 7 or 25 6. It looks like the
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
may be triggering the rotate, but at 6:25am? Can't figure.
The contents of your /etc/cron.daily/logrotate are the same as the default /etc/crontab. /etc/cron.daily/logrotate should be:
Code:
#!/bin/sh
test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate /etc/logrotate.conf
The "daily file date/time rotated at 'Tue Aug 26 07:27:34 CDT 2014'. Not 30 7 or 25 6." could be caused by the /etc/cron.daily jobs before logrotate taking around an hour to run.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.