Somehow, I am finding it difficult to understand tweaking around * parameters with cron.

I wanted a job to run every hour and I used the below setting:

* */1 * * *

But it does not seem to do the job. Could someone please explain the meaning of above and what is needed for the job?

  • Okay, I understand now: The problem is with the * mark, I have put in minute place...*/1 and * in hour place probably mean the same thing though.. – xyz Jan 15 '12 at 15:10
  • 1
    Actually, that looks like it would run every minute! If it is not running at all then you have another problem. What is the string that comes after the part that you posted? – dotancohen Feb 1 '12 at 15:03
  • * means every.
  • */n means every nth. (So */1 means every 1.)

If you want to run it only once each hour, you have to set the first item to something else then *, for example 20 * * * * to run it every hour at minute 20.

Or if you have permission to write /etc/cron.hourly/ (or whatever it is on your system), then you could place a script there.

  • 1
    I thought n, means every nth. What is the difference between n and 1/n then? – xyz Jan 15 '12 at 15:02
  • 7
    n means exactly at n. Like above, 20 means at minute 20. 1/n means starting from 1, every nth. However in practice this is used as 1-2/n, meaning in interval from 1 to 2, every nth. (Note that not all cron implementations supports intervals.) – manatwork Jan 15 '12 at 15:27
  • 5
    +1 to just dropping it in /etc/cron.hourly on any modern machine. We waited decades for it, and that's what it is there for! – Aaron D. Marasco Jan 16 '12 at 2:03

The */1 is redundant, you should use * instead.

* */1 * * *

does not run the job every hour, runs it every minute!
To run a job every hour (at 1:00, 2:00, etc.) use

0 * * * *  

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.