I have a script that I want to run every 5 minutes for 10 seconds.
*/5 * * * * /root/XXX/cronjobs/add-prod.sh
It seems logical to have another cron job that would run every 5 minutes and 10 seconds
that would turn off the 1st cron job.
Something like this:
[FORMULA HERE] /root/XXX/cronjobs/rem-prod.sh
How can we set a formula for "every 5 minutes and 10 seconds" ?
You can do this via timeout. It will kill the process after 10 seconds. It would be better than killing the process externally. Otherwise, jakob22's answer is the best one.
*/5 * * * * /usr/bin/timeout 10 /root/XXX/cronjobs/add-prod.sh
Edit: This is already featured in a comment.
Related
I might be overlooking over already-asked-question, but I have not found it yet. Basically, did I do it right in order to execute job for every minute within 9 AM to 6 PM?
schedule.scheduleJob("*/1 9-18 * * *", function Job())
The cron expression should be 0 * 9-18 ? * * *
It reads 0 seconds, every minute, from 9 to 18 every day, every month, every year.
Use cron expression builder for convenience - something like this:
https://www.freeformatter.com/cron-expression-generator-quartz.html
30 */2 * * * *
this expression runs every 2 minutes starting form 30 seconds. Say for example I'm starting cron job at 5 Pm. cron job start executing at 5:00:30, 5:02:30, 5:04:30 in (HH:MM:Sec). But I need the solution to execute every 2 minutes 30 seconds. like 5:02:30, 5:05:00, 5:07:30 this.
cron only provides the ability to start jobs in minute intervals. However, you can call the sleep program to create a seconds-based offset. NOTE that this is not a high precision scheduling framework; depending on your system load some tasks might be delayed.
# run at minute 2, 7, 12, 17, … then offset by 30 seconds
2-57/5 * * * * sleep 30; your_command
# run at minute 0, 5, 10, 15, … without offset
*/5 * * * * your_command
Find a similar answer here, although the question is phrased a bit differently (execute every 30 seconds)
I am trying to create a cron job that fires every 5 minutes before 30, for example:
10:25,
10:55,
11:25,
11:55 etc. I tried */25,55 * * * * but this also sends messages at 10:50 and I'm not sure why, what would be the correct way to do this?
You're looking for the following, which is simply "at minute 25 and minute 55":
25,55 * * * *
In your original attempt, the expression */25 means "every 25th minute". As such, it would execute at 25 minutes after the hour, and then 25 minutes later.. or 50 minutes after the hour.
I am having troubles with cron syntax,
I want to run cron job every 10 minutes,but not on 10th minute.
it has to run on 20,30,40,50,00 of the hour, not on 10.
How I do this?
10-59/10 * * * * doesn't work.
Add all times when the Job should be executed
0,20,30,40,50 * * * *
I want a cron job to run between 7 AM and 10 PM, every day, at 5 minute intervals. Normally this would be okay if it was 5 minute intervals, because you could just use "/5", but is there a way to specify it as 5 minute intervals but skip the times between 10PM and 7AM?
The minutes are specified separately from the hours in crontab. Specify minutes using the periodic notation, and the hours as a range.
*/5 7-21 * * * /path/to/script
Below would help for Quartz scheduler
0 00/5 7-21 * * ?