Linux – CronJob Every 25 Minutes

cronlinux

I want to know whether there is any easier way to run a job every 25 minutes. In cronjob, if you specify the minute parameter as */25, it'll run only on 25th and 50th minute of every hour

Best Answer

The command in crontab is executed with /bin/sh so you can use arithmetic expansion to calculate whether the current minute modulo 25 equals zero:

*/5 * * * * [ $(( $(date +\%s) / 60 \% 25 )) -eq 0 ] && your_command

cron will run this entire entry every 5 minutes, but only if the current minute (in minutes since the epoch) modulo 25 equals zero will it run your_command.

As others have pointed out, 1 day is not evenly divisible by 25 minutes, so this will not cause your_command to run at the same time every day, but it will run every 25 minutes.

Related Question