There was a thread http://lists.suse.com/archive/suse-linux-e/2005-May/1103.html regarding cron daily in 9.3. The command find /var/spool/cron/lastrun -name cron.daily -printf "%c\n" was given to find the timestamp used by cron to run cron daily. In my trying to restore storeBackup to a functioning backup program, I was revisiting these instructions. I put the rm and touch commands in a crontab, and left my machine on all night (I normally power off my home machine at night) to set it to run at 2:00am. It set the time correctly, according to the above command, but I noticed after it was off last night, and ran the backup soon after starting this am, this timestamp was set to this mornings time, negating the rm and touch commands altogether. Is this the way it is supposed to work? It seems it will just keep changing when it runs depending on what time I turn on my computer, or if I turned on one day at noon, it will run at noon the next day if I turned on a 6am. Am I missing something, or is this the way it is supposed to work? I did make the changes to the /usr/lib/cron/run-crons. -- Joe Morris New Tribes Mission Email Address: Joe_Morris@ntm.org Registered Linux user 231871
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Sunday 2005-11-27 at 12:10 +0800, Joe Morris (NTM) wrote:
the rm and touch commands altogether. Is this the way it is supposed to work? It seems it will just keep changing when it runs depending on what time I turn on my computer, or if I turned on one day at noon, it will run at noon the next day if I turned on a 6am. Am I missing something, or is this the way it is supposed to work? I did make the changes to the /usr/lib/cron/run-crons.
Mine (without changes) seems to run every day 15 minutes later, except if it is powered down at the corresponding time, in which case it runs about 15 minutes after booting. If I touch /var/spool/cron/lastrun/cron.daily, it runs within 15 minutes; similarly, if it was due to run at night, but the computer was off and cron runs at daytime when i switch it on, the flag file will be timestamped daytime, of course. I have just now edited /usr/lib/cron/run-crons: #cron.daily) TIME="-ctime +1 -or -ctime 1" ;; #cron.weekly) TIME="-ctime +7 -or -ctime 7" ;; #bug cron.daily) TIME="-cmin +1400 -or -cmin -1400" ;; cron.weekly) TIME="-cmin +10080 -or -cmin -10080" ;; and I'll see if that fixes the 15' delay. - -- Cheers, Carlos Robinson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFDiawwtTMYHG2NR9URAnKYAJ40TCp1IfJTZPl5ueXMMaZ2cpyrMgCgkqHF oTO/LMN8HW2qUW19P0KW114= =SP7h -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Sunday 2005-11-27 at 13:53 +0100, I wrote:
I have just now edited /usr/lib/cron/run-crons:
#cron.daily) TIME="-ctime +1 -or -ctime 1" ;; #cron.weekly) TIME="-ctime +7 -or -ctime 7" ;; #bug cron.daily) TIME="-cmin +1400 -or -cmin -1400" ;; cron.weekly) TIME="-cmin +10080 -or -cmin -10080" ;;
and I'll see if that fixes the 15' delay.
[...] Well, it is not correct. It ran within 15 minutes of editing /usr/lib/cron/run-crons, even if the flag file was stamped "Nov 27 01:15 cron.daily": Nov 27 01:15:02 nimrodel run-crons[15358]: Starting cron daily run Nov 27 14:00:01 nimrodel run-crons[20757]: Starting cron daily run I'll touch the flag file and see what happens: nimrodel:~ # touch --date="today 01:15:00" /var/spool/cron/lastrun/cron.daily nimrodel:~ # l /var/spool/cron/lastrun/cron.daily - -rw-r--r-- 1 root root 0 Nov 27 01:15 /var/spool/cron/lastrun/cron.daily [...] No! It is running again at 14:30. I think I will undo the changes to the script, it is wrong: it is running every fifteen minutes: Nov 27 01:15:02 nimrodel run-crons[15358]: Starting cron daily run Nov 27 14:00:01 nimrodel run-crons[20757]: Starting cron daily run Nov 27 14:15:01 nimrodel run-crons[21710]: Starting cron daily run Nov 27 14:30:02 nimrodel run-crons[22550]: Starting cron daily run [...] Right, after I undid the change, it stopped running every 15'. I think it will run again at 1:30, which is not so wrong. - -- Cheers, Carlos Robinson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFDicYWtTMYHG2NR9URAtsSAKCJ2LuZjspcqfdO/Ui1Q8LcuZvzrwCfUaPy ZJuAYc4GWrUoT6juysAw7as= =APm2 -----END PGP SIGNATURE-----
Hi, On Sun, 27 Nov 2005 15:43:23 +0100 (CET) "Carlos E. R." <.> wrote:
#cron.daily) TIME="-ctime +1 -or -ctime 1" ;; #cron.weekly) TIME="-ctime +7 -or -ctime 7" ;; #bug cron.daily) TIME="-cmin +1400 -or -cmin -1400" ;; cron.weekly) TIME="-cmin +10080 -or -cmin -10080" ;;
Sorry for this lame reply, but I think something is wrong here. 1 week = 7 days, so 1400 x 7 would be likely 9800 and not 10080. Pelibali Ps. From the archive: <...> cron.hourly) TIME="-cmin +60 -or -cmin 60" ;; cron.daily) TIME="-cmin +1440 -or -cmin 1440" ;; cron.weekly) TIME="-cmin +10080 -or -cmin 10080" ;; cron.monthly) NOW=`date +%s` <...>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Sunday 2005-11-27 at 20:12 +0100, pelibali wrote:
On Sun, 27 Nov 2005 15:43:23 +0100 (CET) "Carlos E. R." <.> wrote:
#cron.daily) TIME="-ctime +1 -or -ctime 1" ;; #cron.weekly) TIME="-ctime +7 -or -ctime 7" ;; #bug cron.daily) TIME="-cmin +1400 -or -cmin -1400" ;; cron.weekly) TIME="-cmin +10080 -or -cmin -10080" ;;
Sorry for this lame reply, but I think something is wrong here. 1 week = 7 days, so 1400 x 7 would be likely 9800 and not 10080.
Let me see. 10080 minutes / (60 minutes/hour) = 168 hours = = 168 hours / ( 24 hour / day) = 7 days. It is correct. The other should be 1440, yes, but that does not explain why it runs every 15 minutes. - -- Cheers, Carlos Robinson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFDijLXtTMYHG2NR9URAlGsAKCDqa43fPfJA6iDeGhJbbn2T/j6lgCfdyPP Tukp+06p+Y1y5pXmqGdOoYk= =sbbe -----END PGP SIGNATURE-----
On Sunday 27 November 2005 15:43, Carlos E. R. wrote:
The Sunday 2005-11-27 at 13:53 +0100, I wrote:
I have just now edited /usr/lib/cron/run-crons:
#cron.daily) TIME="-ctime +1 -or -ctime 1" ;; #cron.weekly) TIME="-ctime +7 -or -ctime 7" ;; #bug cron.daily) TIME="-cmin +1400 -or -cmin -1400" ;; cron.weekly) TIME="-cmin +10080 -or -cmin -10080" ;;
and I'll see if that fixes the 15' delay.
[...]
Well, it is not correct. It ran within 15 minutes of editing /usr/lib/cron/run-crons, even if the flag file was stamped "Nov 27 01:15 cron.daily":
Nov 27 01:15:02 nimrodel run-crons[15358]: Starting cron daily run Nov 27 14:00:01 nimrodel run-crons[20757]: Starting cron daily run
I'll touch the flag file and see what happens:
nimrodel:~ # touch --date="today 01:15:00"
Note that touch doesn't set the ctime, just the mtime, so this won't have any effect.
/var/spool/cron/lastrun/cron.daily nimrodel:~ # l /var/spool/cron/lastrun/cron.daily -rw-r--r-- 1 root root 0 Nov 27 01:15 /var/spool/cron/lastrun/cron.daily
[...]
No! It is running again at 14:30. I think I will undo the changes to the script, it is wrong: it is running every fifteen minutes:
Nov 27 01:15:02 nimrodel run-crons[15358]: Starting cron daily run Nov 27 14:00:01 nimrodel run-crons[20757]: Starting cron daily run Nov 27 14:15:01 nimrodel run-crons[21710]: Starting cron daily run Nov 27 14:30:02 nimrodel run-crons[22550]: Starting cron daily run
This looks strange. Did you remove the section of run-crons which deletes the spool file? Or did you put the line that outputs this message in the wrong place, so it gets printed every time run-crons runs instead of when cron.daily runs?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Monday 2005-11-28 at 00:05 +0100, Anders Johansson wrote:
I'll touch the flag file and see what happens:
nimrodel:~ # touch --date="today 01:15:00"
Note that touch doesn't set the ctime, just the mtime, so this won't have any effect.
Yes, I noticed that later.
No! It is running again at 14:30. I think I will undo the changes to the script, it is wrong: it is running every fifteen minutes:
Nov 27 01:15:02 nimrodel run-crons[15358]: Starting cron daily run Nov 27 14:00:01 nimrodel run-crons[20757]: Starting cron daily run Nov 27 14:15:01 nimrodel run-crons[21710]: Starting cron daily run Nov 27 14:30:02 nimrodel run-crons[22550]: Starting cron daily run
This looks strange. Did you remove the section of run-crons which deletes the spool file?
No, only this change: test -e $SPOOL/$BASE && { case $BASE in cron.hourly) TIME="-cmin +60 -or -cmin 60" ;; cron.daily) TIME="-cmin +1440 -or -cmin -1440" ;; cron.weekly) TIME="-ctime +7 -or -ctime 7" ;; cron.monthly) NOW=`date +%s` ....
Or did you put the line that outputs this message in the wrong place, so it gets printed every time run-crons runs instead of when cron.daily runs?
No, no. It is like this, and it has been there for months now: # stage 2: # run all scripts and collect output into one mail # for each TIME_EXT with a meaningfull subject. # if [ ! -z "${RUN}" ] ; then for EXT in ${RUN} ; do #Cer echo "Starting cron $EXT run"| $LOGGER -p info CRONDIR="/etc/cron."${EXT} .... In fact, it is so strange I did it again (the -cmin thing), exactly as above, at about 00:05 hours. See what I get: Nov 27 14:30:02 nimrodel run-crons[22550]: Starting cron daily run Nov 28 00:15:01 nimrodel run-crons[4086]: Starting cron daily run Nov 28 00:30:01 nimrodel run-crons[4960]: Starting cron daily run Nov 28 00:45:01 nimrodel run-crons[5831]: Starting cron daily run Nov 28 01:00:03 nimrodel run-crons[6663]: Starting cron daily run Nov 28 01:15:02 nimrodel run-crons[8957]: Starting cron daily run Nov 28 01:30:06 nimrodel run-crons[10591]: Starting cron daily run At 1:35 I undid that change, and it hasn't run again. Now it is 02:24, it would have run by now, and it hasn't: so there is something wrong in that script. Very strange! - -- Cheers, Carlos Robinson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFDil1ItTMYHG2NR9URAvA9AJ9RCndW+3uL+VzukGyS/8V/4KmrfgCeKHNb jeWURq3qwEJOgsRPZ0NnJuo= =t642 -----END PGP SIGNATURE-----
On Sunday 27 November 2005 5:28 pm, Carlos E. R. wrote:
No, only this change:
test -e $SPOOL/$BASE && { case $BASE in cron.hourly) TIME="-cmin +60 -or -cmin 60" ;; cron.daily) TIME="-cmin +1440 -or -cmin -1440" ;; cron.weekly) TIME="-ctime +7 -or -ctime 7" ;; cron.monthly) NOW=`date +%s` ....
You might want to check the signs, your's does not at all match mine.... test -e $SPOOL/$BASE && { case $BASE in cron.hourly) TIME="-cmin +60 -or -cmin 60" ;; cron.daily) TIME="-cmin +1440 -or -cmin 1440" ;; cron.weekly) TIME="-cmin +10080 -or -cmin 10080" ;; cron.monthly) NOW=`date +%s` LASTMONTH=`date -d "last month" +%s` DIFF=`expr '(' $NOW - $LASTMONTH ')' / 86400` TIME="-ctime +$DIFF" ;; Note, no negative numbers anywhere. Mine works, I know that much... Scott -- POPFile, the OpenSource EMail Classifier http://popfile.sourceforge.net/ Linux 2.6.11.4-21.9-default x86_64 SuSE Linux 9.3 (x86-64)
Scott, Carlos, On Sunday 27 November 2005 18:25, Scott Leighton wrote:
On Sunday 27 November 2005 5:28 pm, Carlos E. R. wrote:
No, only this change:
test -e $SPOOL/$BASE && { case $BASE in cron.hourly) TIME="-cmin +60 -or -cmin 60" ;; cron.daily) TIME="-cmin +1440 -or -cmin -1440" ;; cron.weekly) TIME="-ctime +7 -or -ctime 7" ;; cron.monthly) NOW=`date +%s` ....
You might want to check the signs, your's does not at all match mine....
test -e $SPOOL/$BASE && { case $BASE in cron.hourly) TIME="-cmin +60 -or -cmin 60" ;; cron.daily) TIME="-cmin +1440 -or -cmin 1440" ;; cron.weekly) TIME="-cmin +10080 -or -cmin 10080" ;; cron.monthly) NOW=`date +%s` LASTMONTH=`date -d "last month" +%s` DIFF=`expr '(' $NOW - $LASTMONTH ')' / 86400` TIME="-ctime +$DIFF" ;;
Note, no negative numbers anywhere. Mine works, I know that much...
Without stopping to really analyze what's being attempted, I'll just point out that with the minus sign on a time value (days or minutes, as the case may be) you're asking for times less than the stipulated number of days or minutes in the past. With a plus sign, you're asking for times greater than the specified time in the past. With neither, you're stating an exact age (though I don't know what sort of epsilon is applied in the comparison and / or the precision with which the comparison is made). Thus Scott's criteria say, to take the cron.hourly case as an example, the file's change time is either less than 60 or greater than 60 minutes, but not "exactly" 60 (whatever "exactly" means to find, as I mention above). It seems unlikely this is really what you intended, but I don't really know that, do I? On the other hand, Carlos' corresponding case says "change time greater than or equal to 60 minutes in the past."
Scott
Randall Schulz
On Sunday 27 November 2005 6:35 pm, Randall R Schulz wrote: Randall,
Thus Scott's criteria say, to take the cron.hourly case as an example, the file's change time is either less than 60 or greater than 60 minutes, but not "exactly" 60 (whatever "exactly" means to find, as I mention above).
It seems unlikely this is really what you intended, but I don't really know that, do I?
I can't speak to the interpretation of what is really going on, but I will comment that the non-minus sign version is the one that the May thread here agreed was the fix for the problem with run-crons. http://lists.suse.com/archive/suse-linux-e/2005-May/1473.html All I know is that I made that fix, without any minus signs, and cron.daily and cron.weekly are running correctly here and have been since May (course, this is a desktop that stays on 24/7 so that may make a difference). Scott -- POPFile, the OpenSource EMail Classifier http://popfile.sourceforge.net/ Linux 2.6.11.4-21.9-default x86_64 SuSE Linux 9.3 (x86-64)
On Monday 28 November 2005 03:25, Scott Leighton wrote:
On Sunday 27 November 2005 5:28 pm, Carlos E. R. wrote:
No, only this change:
test -e $SPOOL/$BASE && { case $BASE in cron.hourly) TIME="-cmin +60 -or -cmin 60" ;; cron.daily) TIME="-cmin +1440 -or -cmin -1440" ;; cron.weekly) TIME="-ctime +7 -or -ctime 7" ;; cron.monthly) NOW=`date +%s` ....
You might want to check the signs, your's does not at all match mine....
test -e $SPOOL/$BASE && { case $BASE in cron.hourly) TIME="-cmin +60 -or -cmin 60" ;; cron.daily) TIME="-cmin +1440 -or -cmin 1440" ;;
argh, I missed that. Yes Carlos, your -1440 tells find to find all files changed *less than* 1440 minutes ago and your +1440 to find all files changed more than 1440 minutes ago. So the only files left untouched by your change are ones changed exactly 1440 minutes ago
participants (6)
-
Anders Johansson
-
Carlos E. R.
-
Joe Morris (NTM)
-
pelibali
-
Randall R Schulz
-
Scott Leighton