-1

I wanted to execute the cron job indefinitely for every 1 minute starting at immediate occurrence of 6:30 AM using the following pattern :

30/1 6 * * *

But cron stops at 6:59 AM and never executes thereafter.

Should I make the pattern as 30/1 6-0 * * *. But I am afraid that the cron may not be invoked after first occurance of 12 AM.

So, will the following pattern resolve the issue? 30/1 6-* * * *

iamauser
  • 11,119
  • 5
  • 34
  • 52
Prem
  • 5,685
  • 15
  • 52
  • 95
  • 1
    You can't have a `cron` that will run at X time and every 1 minute indefinitely. For the former condition, you need to use command like `at` to put the cron file in place during that time. – iamauser Jan 22 '18 at 16:38
  • 1
    What is such a frequent `cron` job *actually* doing? Looks like an [XY problem](http://xyproblem.info), because probably there are better ways to solve your needs. So please, **edit your question** to motivate it and explain what your program is *really* doing every minute – Basile Starynkevitch Jan 22 '18 at 17:01

1 Answers1

2

This runs a cron every 1 minute. For such a high frequency cron job, one should carefully figure out race conditions.

 $ cat ./my1min-cron
 */1 * * * * root /path/to/some/script &> /path/to/some/log

 $ chmod 644 ./my1min-cron

Use at to place it at the next 6:30 AM. For example,

 # Create a script that will copy the cron file to /etc/cron.d/
 $ cat ./putcronscript.sh
 cp -vf ./my1min-cron /etc/cron.d/my1min-cron &> ./copycronscript.log

 # Use at to put the cron script in place at 6:30 AM Tuesday. This is onetime operation.
 $ at -f ./putcronscript.sh 6:30 AM Tue

 # or
 $ at -f ./putcronscript.sh 6:30 AM tomorrow
iamauser
  • 11,119
  • 5
  • 34
  • 52