I have this resque job that must run at 6 AM or 11 AM or 16 PM or 20 PM o clock
or at least for example 6 am
Resque.enqueue_at <what to put here>, SendSmsJob
How do I define specific time like that? thanks
You can pass it a Time and it'll run once that time is in the past, like so:
time = Time.new(2016, 6, 11, 20, 0)
Resque.enqueue_at time, SendSmsJob
Related
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 * ? * * *
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)
Will this expression run the build every other Friday at noon? Assume i set this up on a Friday?
0 12 * * */14
I tried 0 12 * * FRI/14 but Jenkins returned an error.
I ma trying to run a code report job every two weeks to match scrum.
You'll have to add some logic to the build script to determine if it ran last week, and then run it every week.
I looked around similar questions for cron jobs, and you have to do some shell magic to make it work.
You could try what was suggested here:
H H 8-14,22-28 * 5
Which would qualify on Fridays that are in the second or fourth week of the month.
it will run at noon every other friday
00 12 */2 * 5
I had the same issue, the easy work around I found was to create another job that run weekly.
This job was a simple groovy script that does the following:
import jenkins.model.*;
def job = Jenkins.instance.getJob('JobNameToRunEveryTwoWeek')
job.setDisabled(!job.isDisabled())
Since Jenkins does not offer the functionnality its the best easy solution I could find. If you have better solution feel free to let me know.
One ridiculous-looking-but-it-works answer: schedule your job to run every week, and then at the top of the job add the following:
// Suppressing even number builds, so this job only runs
// every other week.
def build_number = env.BUILD_NUMBER as int
if ((build_number % 2) == 0) {
echo "Suppressing even number builds!"
echo """THIS IS A HACK TO MAKE THIS JOB RUN BIWEEKLY.
Jenkins cron scheduling currently doesn't support scheduling a
bi-weekly job. We could resort to shell or other tricks to
calculate if the job should be run (e.g., comparing to the date
of the last run job), it's annoying, and this works just as well.
Schedule this job to run weekly. It will exit early every other week.
refs:
* https://stackoverflow.com/questions/33785196/i-want-jenkins-job-to-build-every-two-weeks
* https://issues.jenkins-ci.org/browse/JENKINS-19756
"""
currentBuild.result = 'SUCCESS'
return
}
For Jenkins, you can try this approach as well.
1 1 8-14,21-28 * 5
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.
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