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
1
  • next time read the man or one of the numerous questions asked here in the same topic
    – asdmin
    Oct 29, 2009 at 20:44

4 Answers 4

14

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

1
  • Ah ok, now I understand, sorry new to crons
    – Elitmiar
    Oct 29, 2009 at 15:05
5

"every minute" has to be entered like this:

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

5
  • 4
    You don't need the /1.
    – womble
    Oct 29, 2009 at 15:17
  • But it won't throw any errors, right?
    – user24393
    Oct 29, 2009 at 15:20
  • 2
    I prefer the /1, it's more explicit. Oct 29, 2009 at 15:30
  • 6
    So shouldn't that be */1 */1 */1 */1 */1 for consistency?
    – womble
    Oct 29, 2009 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 ;)
    – user24393
    Oct 30, 2009 at 8: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

1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .