How do set cron to run my script every 40mins/25mins?
It always splits the current hour only.
40/40 = 1 so it runs every 40th minute of an hour.
*/5 would do 5, 10, 15...
You should go for larger intervals.
Do */30 for your 25 minute interval and every 60 minutes for your 40 minutes interval.
Otherwise set up two crontabs for your script:
0,40 */2 * * * /path/to/script/foo.sh
20 1,3,5,7,9,11,13,15,17,19,21,23 * * * /path/to/script/foo.sh
For the task you want to accomplish you have to write a little bit more complex entry in your crontab.
You see the pattern above?
00:40, 01:20, 02:00, 02:40, 03:20 and again 04:00, 04:40, 05:20, 06:00, 06:40, 07:20, 08:00
I can break it down into three entries:
- Every even hour you have to run it at 40th min
- Every odd hour you have to run it at 20th min
- Every even hour you have to run it on 0. (Except 0 hour)
You can accomplish this with more than one entries:
#1
*/40 0,*/2 * * * /path/to/script/foo.sh
#2
*/20 1,*/2 * * * /path/to/script/foo.sh
#3
0 2,*/2 * * * /path/to/script/foo.sh
NOTE: It might have minor issues, but there I gave you direction :)
PS: This will explain alot more