Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can make cron job which happen at different hours and minutes

Tags:

linux

cron

centos

I want to make crontab where script occurs at different minutes for each hour like this

35 1,8,12,15,31 16,18,21 * * 0,1,2,3,4,5,6 python backup.py

I want script to run at 16hour and 31 minutes but it is giving me error bad hour

i want the cron occur at

1:35am , then 16:31, then 21:45

like image 851
user22 Avatar asked Mar 24 '23 05:03

user22


1 Answers

As there is not a pattern that can match the three times, it is not possible to schedule that just with one crontab expression. You will have to use three:

45 21 * * * python backup.py
31 16 * * * python backup.py
35 1 * * * python backup.py

Note also that python backup.py will probably not work. You have to define full path for both files and binaries:

35 1 * * * /usr/bin/python /your/dir/backup.py

Where /usr/bin/python or similar can be obtained with which python.

like image 143
fedorqui 'SO stop harming' Avatar answered Apr 05 '23 20:04

fedorqui 'SO stop harming'