edd
edd

Reputation: 291

How can I create a custom crontab?

I want a crontab to run every 15 minutes starting from 9:45 to 16:00.

I currently have this:

crontab(minute='*/15', hour='9:45-16', day_of_week='mon,tue,wed,thu,fri')

but 9:45 is not valid

Is there any way to solve this?

Upvotes: 0

Views: 68

Answers (2)

Read crontab(5). Run crontab(1) or edit /etc/crontab according to your needs (perhaps using emacs thru sudo). Of course you might use some Python library editing these textual files.

I see no reason to use Python for your purposes. Of course, you could run your Python script from cron, or any other executable. See execve(2). Beware that your $PATH could be different for a script started from cron and in your interactive shell.

Upvotes: 1

jaswanth
jaswanth

Reputation: 525

for this purpose you cannot do this in one command it is better to do it in two cron commands

crontab(minute='*/15', hour='10-16', day_of_week='mon,tue,wed,thu,fri')
crontab(minute='45', hour='9', day_of_week='mon,tue,wed,thu,fri')

Upvotes: 3

Related Questions