Change the time that cron.daily is run
Hey, all -- I'm trying to figure out how to change the time that the scripts in cron.daily are run. Currently they're processed right around 2 AM, 2:05 I think. This seems to be the default for 9.3. For various reasons, I need some of them to run between 12:30 and 1 AM. It used to be possible to change the single line that controlled cron.daily (for example) in /etc/crontab. However, it seems that all of the scheduled scripts are now controlled by calling /usr/lib/cron/run-crons each hour. It's not clear to me where the config info comes from that tells run-crons on which hour to run the cron.daily scripts. Anyone have any pointers?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Sunday 2005-11-27 at 10:36 -0500, Ian Marlier wrote:
I'm trying to figure out how to change the time that the scripts in cron.daily are run.
Currently they're processed right around 2 AM, 2:05 I think. This seems to be the default for 9.3.
No, that's not the way it works. It runs - it should run - at the same time as the last day. If the computer is powered off at the time it should run, it will run within 15 minutes of booting up, ant then it will at that same time the nextday and there after. The method ensures it runs once every 24 hours (if powered up), but not when. And in fact, it has a bug that makes it run 15 minutes later each day.
For various reasons, I need some of them to run between 12:30 and 1 AM.
Then, create a crontab entry that runs: touch /var/spool/cron/lastrun/cron.daily at 12:14 exactly.
It used to be possible to change the single line that controlled cron.daily (for example) in /etc/crontab. However, it seems that all of the scheduled scripts are now controlled by calling /usr/lib/cron/run-crons each hour. It's not clear to me where the config info comes from that tells run-crons on which hour to run the cron.daily scripts.
There is no config. Study what that script does and you will find out.
Anyone have any pointers?
Search the archive, you will see this has been talked about several times. - -- Cheers, Carlos Robinson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFDijUetTMYHG2NR9URAgBOAJ9HkCvs5aD8Chq2j41prT33Q4EzYQCePNXa u6cQzDGluWbCDTaDXw9u3Ow= =KvLl -----END PGP SIGNATURE-----
I'm trying to figure out how to change the time that the scripts in cron.daily are run.
Currently they're processed right around 2 AM, 2:05 I think. This seems to be the default for 9.3.
For various reasons, I need some of them to run between 12:30 and 1 AM. You need to delete /var/spool/cron/lastrun/cron.daily just before you want the daily cron scripts to run (and then AFAIU) as long as your computer is always on, it will continue to run at those times. I put /bin/rm /var/spool/cron/lastrun/cron.daily in roots crontab to do it, you could do it at 12.25 I believe and it would get run at 12:30. Check
Ian Marlier wrote: the archives, there was a thread regarding this back in April 2005 -- Joe Morris New Tribes Mission Email Address: Joe_Morris@ntm.org Registered Linux user 231871
On Mon, 28 Nov 2005, Joe Morris (NTM) wrote:
I'm trying to figure out how to change the time that the scripts in cron.daily are run.
Currently they're processed right around 2 AM, 2:05 I think. This seems to be the default for 9.3.
For various reasons, I need some of them to run between 12:30 and 1 AM. You need to delete /var/spool/cron/lastrun/cron.daily just before you want the daily cron scripts to run (and then AFAIU) as long as your computer is always on, it will continue to run at those times. I put /bin/rm /var/spool/cron/lastrun/cron.daily in roots crontab to do it, you could do it at 12.25 I believe and it would get run at 12:30. Check
Ian Marlier wrote: the archives, there was a thread regarding this back in April 2005
Strewth. If I understand the scripts correctly, they're supposed to run stuff every 24 hours from when last run. This will pick up the case where machines are turned off at the nominated time. More usually, in my experience, /etc/crontab specifies when to run cron.* - RH does it around 04:00, Debian around 06:00. It's an easy, standard way to do it and sysadmins can learn on one distro and carry their skills to another. In contrast, users moving from/to SUSE have otherwise unnecessary relearning to do. RH picks up the case when the machine was down at the due time with anacron. Apart from being different, it seems to me that the SUSE behaviour may be for execution times to drift with systems that are always on, and to run on boot when users want to do stuff with machines that are regularly turned off overnight - eg work desktops. I found the Debian behaviour inconvenient - I often am using my computer at 06:00, so I moved it to 04:00 and it was easy to configure, not requiring Joe's Crude Hack. I suggest those adversely affected report/add to a bug regarding this, and categorise it as a "request for enhancement."
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Monday 2005-11-28 at 07:31 +0800, John Summerfield wrote:
I suggest those adversely affected report/add to a bug regarding this, and categorise it as a "request for enhancement."
It has been this way for years. - -- Cheers, Carlos Robinson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFDilWvtTMYHG2NR9URAiACAJ4lrZs+VnfjqsRfFu7VAxvwD0OnlwCfW4xW oyvHQ0O4B9Mm6LVKBeFhNJk= =/YGk -----END PGP SIGNATURE-----
Carlos, On Sunday 27 November 2005 16:56, Carlos E. R. wrote:
The Monday 2005-11-28 at 07:31 +0800, John Summerfield wrote:
I suggest those adversely affected report/add to a bug regarding this, and categorise it as a "request for enhancement."
It has been this way for years.
That's a non-sequitur. The fact that a behavior is old doesn't mean it could not bear improvement. I mildly dislike the current behavior (it's insufficiently stable and not subject to my direct control) and would like to see a means of explicitly configuring the nominal time at which these housekeeping actions take place. The fact that it actively tries to catch up if it misses a scheduled run is good, of course. And I can see why for some people adapting permanently to that time might be good, based on the inference that if the system wasn't up at, say, 4:00 AM one day, it may not be an always-on system and a different time for daily chores should be chosen. But for those who do run an always-on system, shifting the scheduled time after missing one scheduled run is less the optimal, to say the least. Right now, I've got the beagle scan, rkhunter and updatedb running at 4:30 PM. On days when I'm in the office, that's not a problem, but that's barely a majority of the week (since I usually work one day at home). And like John S., 6:00 AM would not be good, 'cause I'm often up and working then (OK, so I'm reading the mail the accumulated overnight). I'm not even sure what caused the execution to move to this odd hour, but it happened when I installed (not upgraded to) 10.0. The last time it was off, I went through the rigamarole of manipulating the mod time (or change time, whatever it is) of the time-stamp file, but I'm disinclined to do that again (I mistyped and screwed up my system clock for a while, and that's just not cool).
-- Cheers, Carlos Robinson
Randall Schulz
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Sunday 2005-11-27 at 17:49 -0800, Randall R Schulz wrote:
It has been this way for years.
That's a non-sequitur. The fact that a behavior is old doesn't mean it could not bear improvement.
I mildly dislike the current behavior (it's insufficiently stable and not subject to my direct control) and would like to see a means of explicitly configuring the nominal time at which these housekeeping actions take place. The fact that it actively tries to catch up if it misses a scheduled run is good, of course. And I can see why for some people adapting permanently to that time might be good, based on the inference that if the system wasn't up at, say, 4:00 AM one day, it may not be an always-on system and a different time for daily chores should be chosen. But for those who do run an always-on system, shifting the scheduled time after missing one scheduled run is less the optimal, to say the least.
As a quick "solution", I think you can simply remove the flag file a pair of minutes before your prefered time for the runs to occur - not, as I thought previously, touching that file. Ie, if you delete '/var/spool/cron/lastrun/cron.daily' at 1:28 AM, it will run at 1:30 AM; this can be done as a cronjob, or with the command "at" for one shot. As an alternative, if you have a preferred timeframe when you'd like these daily chores to run, would be to edit the crontab entry (in '/etc/crontab'). Right now (SuSE 9.3) I have: - -*/15 * * * * root test -x /usr/lib/cron/run-crons && /usr/lib/cron/run-crons >/dev/null 2>&1 If I wanted it to only run somewhere in the early hours, I could use: - -*/15 0-6 * * * root test .... but then, cron.hourly would not run during the day. Else, as there are people here fluent with script writing, someone could think of a modification of the /usr/lib/cron/run-crons script to run at certain prefered hours, and/or not to run at certain hours, as a variable in '/etc/sysconfig/cron' perhaps. - -- Cheers, Carlos Robinson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFDi1lotTMYHG2NR9URAvHpAKCFWr+IgbvkSrWvckKTkAUWVyfYVACeJwyh eeeAIO9Vux5fvsbgfE4GjEM= =/5tf -----END PGP SIGNATURE-----
On 11/27/05 7:56 PM, "Carlos E. R."
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
The Monday 2005-11-28 at 07:31 +0800, John Summerfield wrote:
I suggest those adversely affected report/add to a bug regarding this, and categorise it as a "request for enhancement."
It has been this way for years.
I'm with John and Randall on this one; persistence doesn't imply that it's optimal. Having the time at which cron.* scripts are run be configurable is useful for a variety of reasons.
On 11/27/05 5:55 PM, "Joe Morris (NTM)"
I'm trying to figure out how to change the time that the scripts in cron.daily are run.
Currently they're processed right around 2 AM, 2:05 I think. This seems to be the default for 9.3.
For various reasons, I need some of them to run between 12:30 and 1 AM. You need to delete /var/spool/cron/lastrun/cron.daily just before you want the daily cron scripts to run (and then AFAIU) as long as your computer is always on, it will continue to run at those times. I put /bin/rm /var/spool/cron/lastrun/cron.daily in roots crontab to do it, you could do it at 12.25 I believe and it would get run at 12:30. Check
Ian Marlier wrote: the archives, there was a thread regarding this back in April 2005
That was very helpful, Joe. Thank you. - Ian
participants (5)
-
Carlos E. R.
-
Ian Marlier
-
Joe Morris (NTM)
-
John Summerfield
-
Randall R Schulz