Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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
    
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
add comment

1 Answer

up vote 16 down vote accepted
  • * 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.

share|improve this answer
    
I thought n, means every nth. What is the difference between n and 1/n then? –  xyz Jan 15 '12 at 15:02
5  
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
3  
+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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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