0

I want to run a script through linux cron which will run after 9 hour.

For example: If current time is 00:34 and I start the cron now, then my shell script should run at 00:34 and then at 09:34 and at 18:34 and so on. For this I have entered the below cron :

34 */9 * * * /path/to/script/foo.sh

But this is not working as expected. So, Any help would be helpful.

Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186

1 Answers1

0

I don't think its possible to do that for every 9 hour window. The way you have currently scheduled it, it will run at 00:34, 09:34, 18:34 every day and not in 00:34, 09:34, 18:34, 3:34, 12:34 fashion.

You should instead run it every 3 hours (24 hours/day, 3 is the highest common factor between 24 and 9), using an interim file for storing whether it is the first, second or third 3-hour window of the 9 hours. Based on this value, run the task whenever its the first such window.

Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186