简体   繁体   中英

How to run a cron job for every 2 minutes 30 seconds

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM