3

I have a cron that needs to run every minute

I tried

1 * * * * php /scripts/cron.php

but seems not to run every minute, why? Since in the minute tab I entered 1 for every minute

but the following runs every minute

* * * * * php /scripts/cron.php
Elitmiar
  • 775
  • 3
  • 15
  • 31

4 Answers4

14

1 in the first column doesn't mean "every minute", it means "one minute past the hour".

womble
  • 96,255
  • 29
  • 175
  • 230
5

"every minute" has to be entered like this:

*/1 * * * * php /scripts/cron.php

  • 4
    You don't need the `/1`. – womble Oct 29 '09 at 15:17
  • But it won't throw any errors, right? –  Oct 29 '09 at 15:20
  • 2
    I prefer the /1, it's more explicit. – Kamil Kisiel Oct 29 '09 at 15:30
  • 6
    So shouldn't that be `*/1 */1 */1 */1 */1` for consistency? – womble Oct 29 '09 at 16:03
  • Not necessarily, that's too much :) Rhe guy is new to crontab and I just wanted to show him how the right syntax for "every something" looks like. There was no need to hit negative rating since there was nothing wrong with the instructions. Difference between personal preferences doesn't mean that one solution is wrong or superior in any way than another ;) –  Oct 30 '09 at 08:58
1

The column is the minutes in the hour to run the command, not how often to run

You could go with

1,2,3,4, all the way up to 59 * * * * php /scripts/cron.php if you were bored and wanted to list out every minute manually, or you could just do what you've actually done, the * means "run every time".

Ewan

Ewan Leith
  • 1,705
  • 8
  • 7
1

Nice explanation is on wikipedia.org: http://en.wikipedia.org/wiki/Cron#Operators

jomey
  • 312
  • 1
  • 3