tasks.cfg - strange CRONDATE behaviour
Hi,
Can anyone else confirm this. I have in tasks.cfg, something like so :-
[xxx_refresh] ENVFILE /apps/xymon/server/etc/xymonserver.cfg CMD /apps/scripts/xxx_refresh.sh LOGFILE $XYMONSERVERLOGS/xxx_refresh.log CRONDATE 15 8-18 * * 1-5
What I deduce by adding echo statements to xxx_refresh.sh, is that if this shell script completes in less than 60 seconds, xymonlaunch runs it a second time :-
grep Running xxx_refresh.log Running as pid 10044 at Mon Jun 2 08:15:03 BST 2014 Running as pid 29168 at Mon Jun 2 09:15:04 BST 2014 Running as pid 15931 at Mon Jun 2 10:15:03 BST 2014 Running as pid 17089 at Mon Jun 2 10:15:59 BST 2014 Running as pid 2805 at Mon Jun 2 11:15:02 BST 2014 Running as pid 4021 at Mon Jun 2 11:15:59 BST 2014 Running as pid 22545 at Mon Jun 2 12:15:00 BST 2014 Running as pid 23730 at Mon Jun 2 12:15:57 BST 2014
I have added a (redundant?) INTERVAL keyword, I have also played around with GROUP, but i cant stop it running twice. Presumably adding a sleep at the end of the script would be a workaround, I'll try that next.
Andy
Interesting. Does this only happen when the run timestamp is on or near the start of each minute? I'm testing this now, with a CRONDATE specification of "*/2 * * * *" (to run every 2 minutes) but I'm not seeing the same behaviour - it runs only once every 2 minutes. I might have to wait until the run time drifts towards the start of the minute to see the same thing as you.
On Monday, 2 June 2014, Andy Smith <abs at shadymint.com> wrote:
What I deduce by adding echo statements to xxx_refresh.sh, is that if this
shell script completes in less than 60 seconds, xymonlaunch runs it a second time :-
On Tuesday, 3 June 2014, Jeremy Laidman <jlaidman at rebel-it.com.au> wrote:
Interesting. Does this only happen when the run timestamp is on or near the start of each minute? I'm testing this now, with a CRONDATE specification of "*/2 * * * *" (to run every 2 minutes) but I'm not seeing the same behaviour - it runs only once every 2 minutes. I might have to wait until the run time drifts towards the start of the minute to see the same thing as you.
Yep, when it drifted to 2 seconds after the minute mark I started seeing my script run twice. When 3 seconds after the minute, it only runs once. Although on one occasion when at 2 seconds past the minute, it only ran once.
Tue Jun 3 15:48:03 EST 2014 Tue Jun 3 15:50:02 EST 2014 Tue Jun 3 15:50:59 EST 2014 Tue Jun 3 15:52:03 EST 2014 Tue Jun 3 15:54:02 EST 2014 Tue Jun 3 15:54:58 EST 2014 Tue Jun 3 15:56:03 EST 2014 Tue Jun 3 15:58:02 EST 2014 Tue Jun 3 16:00:00 EST 2014 Tue Jun 3 16:00:57 EST 2014 Tue Jun 3 16:02:02 EST 2014 Tue Jun 3 16:04:00 EST 2014 Tue Jun 3 16:04:57 EST 2014 Tue Jun 3 16:06:00 EST 2014 Tue Jun 3 16:06:58 EST 2014
etc.
J
Jeremy Laidman wrote:
On Tuesday, 3 June 2014, Jeremy Laidman <jlaidman at rebel-it.com.au <mailto:jlaidman at rebel-it.com.au>> wrote:
Interesting. Does this only happen when the run timestamp is on or near the start of each minute? I'm testing this now, with a CRONDATE specification of "*/2 * * * *" (to run every 2 minutes) but I'm not seeing the same behaviour - it runs only once every 2 minutes. I might have to wait until the run time drifts towards the start of the minute to see the same thing as you.Yep, when it drifted to 2 seconds after the minute mark I started seeing my script run twice. When 3 seconds after the minute, it only runs once. Although on one occasion when at 2 seconds past the minute, it only ran once.
Tue Jun 3 15:48:03 EST 2014 Tue Jun 3 15:50:02 EST 2014 Tue Jun 3 15:50:59 EST 2014 Tue Jun 3 15:52:03 EST 2014 Tue Jun 3 15:54:02 EST 2014 Tue Jun 3 15:54:58 EST 2014 Tue Jun 3 15:56:03 EST 2014 Tue Jun 3 15:58:02 EST 2014 Tue Jun 3 16:00:00 EST 2014 Tue Jun 3 16:00:57 EST 2014 Tue Jun 3 16:02:02 EST 2014 Tue Jun 3 16:04:00 EST 2014 Tue Jun 3 16:04:57 EST 2014 Tue Jun 3 16:06:00 EST 2014 Tue Jun 3 16:06:58 EST 2014
etc.
Just to confirm, with a sleep in the script, my tasks ran only once. It is not a solution I want to stick with going forward but I havent had time to look at the code yet to see why this might be happening.
Andy
On Tuesday, 3 June 2014, Jeremy Laidman <jlaidman at rebel-it.com.au> wrote:
Yep, when it drifted to 2 seconds after the minute mark I started seeing my script run twice. When 3 seconds after the minute, it only runs once. Although on one occasion when at 2 seconds past the minute, it only ran once.
Looks like a logic bug. The code (xymonlaunch.c) runs a loop for all tasks, with a 5 second sleep between each run, giving up to 12 loop cycles per minute. For CRONDATE entries, it refuses to run a task if the last time the task was run was within 55 seconds of the current time. That opens up the possibility for a job to run at 1 second past the minute and again at 57 minutes past the minute (or 58 or 59). If the xymonlaunch loop takes more than a 3/12 of a second, then at the end of 12 loop cycles, it will be into the next minute. But if it takes a little more time, it would go back into that danger zone (57, 58 or 59 seconds) after only 11 cycles.
Seems to me that a better way would be, instead of seeing if the last run timestamp was at least 55 seconds before now, check if the last run timestamp "minute" was the same as now. This could be easily implemented, I would think, by seeing if int(laststart / 60) is equal to int(now/60).
J
participants (2)
-
abs@shadymint.com
-
jlaidman@rebel-it.com.au