3

Is there a way to run a cron job once a minute for an hour every day?

I know I can probably make 60 cron jobs to do this but that would make it difficult if I ever needed to edit the job.

migrated from stackoverflow.com Apr 4 '12 at 10:53

This question came from our site for professional and enthusiast programmers.

6

Sure:

*/1 4 * * * /home/scripts/my_job.sh

That tells it to run every minute during the 4 AM hour.

  • @ davidethell. that is cool. I never used it – Jayan Apr 3 '12 at 11:24
  • Isn't the /1 redundant? – Daniel Beck Aug 19 '12 at 13:22
  • Could you explain how the /1 works. Some other users would like to make it ever '15 minutes for 2 hours' say... – Pureferret Sep 4 '12 at 21:47
  • @DanielBeck, yes, /1 is redundant. * will accomplish the same thing. – davidethell Sep 5 '12 at 10:25
  • 1
    @Pureferret, the /1 says every minute. To make it run every 15 minutes just to /15. For the hours you can specify a two hour range like 2-4. So this would work: */15 2-4 * * * – davidethell Sep 5 '12 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy