In our .NET application, we have several hourly job triggers:
XX:00
XX:05
XX:10
XX:15
During the end of DST (25 October 2020 at 03:00) the triggers stopped working except the first trigger (XX:00).
Hour 00 did well. Hour 01 also did well. But starting with hour 02 only the trigger at 02:00 worked. The three other triggers never got triggered, even later during the day it didn't work. They completely stopped working except the trigger for XX:00 kept working.
I can't clarify why it behaved like this, because DST ended at 03:00 so I think 02:00 should have worked normally until 03:00. Probably after 03:00 I should have seen some misbehaviour but the misbehaving happened at hour 02 as I mentioned earlier.
I'm very flexible in solving this issue. I can change the schedules to semi-hourly or to 2-hourly if it solves the issue. The 4 triggers just have to keep triggering instead of stopping completely... It doesn't matter when they run, as long as they trigger approximately every hour continuously. But SimpleTrigger isn't the one that I want to use, because then all the jobs start immediately in parallel when service starts and I don't want that...
I know there are similar questions here on SO, but in most of those questions the timing is stubborn. In my case, I'm very flexible and I'm looking for the easiest workaround.
Is there any quick workaround to solve this issue? Can I for example completely ignore DST and just use UTC?
Using library version: 3.0.7
The CRON triggers:
0 0 * ? * * *
0 5 * ? * * *
0 10 * ? * * *
0 15 * ? * * *
Related
I have scheduled rufus cron to run a method (a method to post a complex query in remote DB, retrieves result and, do some processing ) every hour and 99% of time the methods completes execution <1 hr.
Rufus fires the method fine at every expected time, but the problem is some times (1% fo time) the method wont complete in a hour; the scheduler fires the second one at the expected time and fires the second one again, on completion of previous run.
For example,
pin_sampling_job_scheduler = Rufus::Scheduler.new
pin_sampling_job_scheduler.cron("22 * * * *") do
puts "sampling starts"
DatafetchRedshift.pin_sampling_job
end
for hour = 00, the method fires at 22nd min(as expected and assume the job is running for 1.5 hour) For hour =01, method is fires at 22nd min and again at 52nd min (after completion of first run). Why is it happening like this? Any help or suggestion will be appreciated.
Rufus version -3.3.4
Rails - 4.1.6
Ruby 2.2.0
P.S - I wont be able to change the scheduler runs to be more than an hour, since 99% it completes
https://github.com/jmettraux/rufus-scheduler#overlap--false
pin_sampling_job_scheduler = Rufus::Scheduler.new
pin_sampling_job_scheduler.cron("22 * * * *", overlap: false) do
ts = Time.now.strftime('%Y%m%d%H%M')
puts "#{Time.now} - sampling #{ts} starts..."
DatafetchRedshift.pin_sampling_job
puts "#{Time.now} - sampling #{ts} stopped."
end
for hour = 00, the method fires at 22nd min(as expected and assume the job is running for 1.5 hour) For hour =01, method is fires at 22nd min and again at 52nd min (after completion of first run). Why is it happening like this?
You can report issues at https://github.com/jmettraux/rufus-scheduler/issues (please read https://github.com/jmettraux/rufus-scheduler#getting-help before filing an issue)
All,
Tried to configure jenkins job to trigger at EVERYDAY 10AM and used below cron H 10 * * * but the jenkins console is not running at 10AM rather its running at 10.09AM. Please help me to run at 10AM everyday around the year.
update: After adding the expression with '0 10 * * *', got below warning and no next run time is displayed. is that normal?
30 5 * * *
will run every day at 5:30 AM
#daily
will run the job once a day at some time, chosen by Jenkins
0 10 * * *
will run every day at 10:00 AM
When not using 'H' in the beginning you will get the warning, you will not get a tip when the job will or would have run, but it will still be active, i.e. it will run as per the statement.
You will always see a syntax error in red color when making any syntax errors.
Also, a good idea might be to create a dummy job to experiment with cron trigger, if you don't feel comfortable with it yet. Or use crontab on Linux:
crontab -e
man crontab
If you really want it at 10AM, please use 0 10 * * *
or 5:30 AM as you asked in comment
30 5 * * *
Jenkins will warn you in this case. If every job schedules like this, load suddenly goes up. Jenkins advice you to differ job time a bit. The H indicate once in every hour, not particularly at 0th minute.
How can I set Jenkins to run a job at a particular time?
Like if I'd like to set it to 8:30am every weekday and this is what I could do
H 7 * * 1-5
this randomly picks up 7:35am as running time.
H is a pseudo-random number, based on the hash of the jobname.
When you configured:
H 7
you are telling it:
At 7 o'clock, at random minute, but that same minute very time
Here is the help directly from Jenkins (just click the ? icon)
To allow periodically scheduled tasks to produce even load on the system, the symbol H (for “hash”) should be used wherever possible. For example, using 0 0 * * * for a dozen daily jobs will cause a large spike at midnight. In contrast, using H H * * * would still execute each job once a day, but not all at the same time, better using limited resources.
The H symbol can be used with a range. For example, H H(0-7) * * * means some time between 12:00 AM (midnight) to 7:59 AM. You can also use step intervals with H, with or without ranges.
The H symbol can be thought of as a random value over a range, but it actually is a hash of the job name, not a random function, so that the value remains stable for any given project
If you want it at 8:30 every weekday, then you must specify just that:
30 8 * * 1-5
Take a look at http://www.cronmaker.com/
0 30 8 ? * MON,TUE,WED,THU,FRI *
30 8 * * 1-5
This would start at 8:30am Mon-Fri.
0 and 7 are Sundays.
Not sure what the H does but I am assuming it takes the lower case hex of h and applies 68 which is 35 in decimal... lol. Don't do that.
Following this format:
Minute Hour DayOfMonth DayOfWeek Day
It picks that time because you told it that it can, as imagine you already know:
minute, hour, day of month, month, day of week.
Now you have user H which allows Jenkins to pick at random. So you have told it to run between 7-8 every week day.
Change this to:
30 8 * * 1-5
Hope this helps!
A build that takes about three hours to complete needs to be scheduled for nightly building outside office hours: not sooner than 22:00 and not later than 3:59 next day.
I'd also like to use the "H symbol" to avoid collision with future nightly builds. From in-line help in Jenkins:
To allow periodically scheduled tasks to produce even load on the system, the symbol H (for “hash”) should be used wherever possible. For example, using 0 0 * * * for a dozen daily jobs will cause a large spike at midnight. In contrast, using H H * * * would still execute each job once a day, but not all at the same time, better using limited resources.
(How) can I schedule this using Jenkins? What I've tried was all considered invalid by Jenkins:
H H(22,23,0,1,2,3) * * *
Invalid input: "H H(22,23,0,1,2,3) * * *": line 1:7: expecting "-", found ','
H H22,23,0,1,2,3 * * *
Invalid input: "H H22,23,0,1,2,3 * * *": line 1:4: unexpected token: 22
H H(22-3) * * *
Invalid input: "H H(22-3) * * *": line 1:9: 1 is an invalid value. Must be within 1
and -18
Is it possible to achieve this without using plug-ins?
I think the closest you will get is to use:
H H(0-3) * * * This will run at some point between 0:00 and 3:59
#midnight This will run at some point between 0:00 and 2:59
The H(4-8) construct only works if the second items is larger then the first.
But you might as well fill in the hour yourself. Jenkins actually never changes the hour the jobs runs once it is set. It will basically create some random hour once you save the job and always run the job at that particular time.
Of course, you can also file a bug report or feature request that you should be able to specify this as H(22-3) or better, fix the code and submit a patch ;)
There is no direct support to write the expression like this, but since there is timezone support (now), you can work around this.
# DONT COPY PASTE - THIS DOESNT WORK!
# This is what we would like to write, but is not supported
H H(22-3) * * *
Above expression means we want to build somewhen between 22 PM and 3 AM, this is a 5 hour period, so we could write:
# Assuming we're in GMT+2 we can just shift the timezone
# so 22-03 becomes 10-15 wich is 12 hours earlier so the
# timezone is GMT-10
TZ=Etc/GMT-10
H H(10-15) * * *
I found this workaround in the comments of JENKINS-18313
UPDATE:
There is currently a bug JENKINS-57702 and the timezone GMT-XX is not evaluated correctly. A workaround is to use a equivalent timezone, in this example the one for Hawaii:
TZ=US/Hawaii
H H(10-15) * * *
I'm trying to run a PHP script from CRON every 15 minutes from 9AM to 6PM during Monday to Friday. My problem is the server is set to CST and my client is on GMT+8. I believe (please do correct me if I'm mistaken) we have a time difference of 13 hours. I'd like to check if the following settings are correct:
*/15 20-23 * * 2-7 wget -O - http://www.mysite.com/myscript.html
*/15 00-05 * * 2-7 wget -O - http://www.mysite.com/myscript.html
Pardon me. This is the first time I'm using CRON.
Thanks in advanced.
What you have looks OK except when daylight saving time changes occur. What will you do then? One option is to expand your window by an hour so that you run the job for an extra hour on one side during winter and the other side during summer. If that's not OK for some reason, you'll need to either change the server's timezone, change your script to check the time, or use this patch from OpenSolaris, which adds special TZ support to cron:
http://blogs.oracle.com/chrisg/entry/timezone_aware_cron_finally_pushed