Rohanil
Rohanil

Reputation: 1887

crontab settings with start_time and interval

I have a linux cron job to run. I want to configure its setting. What I have is, start_time for the job and interval after which it should repeat every time. interval is integer and has unit of day. So for example, I want to set up cron job starting on some random date in future and want to run that job periodically after every interval days. I tried to do 0 0 * * */interval but it does not give what I want. Any idea how to achieve it?

Upvotes: 0

Views: 708

Answers (1)

Brae
Brae

Reputation: 514

I think you may want something like

0 0 */interval * * /your/command

Basically switching day of week for day of the month. As for the random start date, that will have to be done somewhere else I think, like with a shell script which edits the cron file at a certain point etc.

EDIT: This little script would allow you to edit the cron file.

#!/bin/sh
crontab -l > tempcron
echo "00 00 * * * /bin/ls" >> tempcron #just an example cron
crontab tempcron
rm tempcron

Upvotes: 1

Related Questions