-1

I got a cron format like this:

0 0 12 1/1 * ? *,

How to read it and what does it mean. I understand things without slash but not this one.

  • 5
    See the crontab(5) manpage. – jordanm Sep 11 '15 at 15:17
3

Slashes means step values (has to be something that the maximum value of the element in question is divisible by) in which the execution will take place. First value is the range, so say 0-30, and the second value is the frequency, so for example 5. If the value was 0-30/5 in the minutes column, it would execute every five minutes between the range of 0-30 minutes.

Question marks mean whenever the first execution takes place, it'll grab the corresponding value for the element using a question mark, and will put the value at that time into it. This means, say you start the execution via cron for the first time on a Monday and the day of the week value is a ?, it'll change it to a Monday so it runs on Monday permanently.

Quick run-down of the values:

0 - first column means on the 0 minute - this is what minute to execute.

0 - second column means on the 0 hour - this is the hour of execution.

12 - this is the 12th day of the month - this is the day of the month to execute.

1/1 - this means it wants it to be executed once a month (right hand side 1), and the range is locked down to the first month (left hand side 1). If my understanding is correct, this is the same as having 1 alone.

* - this is the value for the day of the week - having an asterisk means it'll be repeated every day of the week.

This looks like it'll run at 00:00 on the 12th of the first month in the year, regardless of the day of the week.

I'm not sure why there are seven values, as standard cron files only have five or six values from what I'm aware (sixth being the year, as viewable in the documentation below - but is not included in standard/default deployments of cron). I'd also suggest having a read through the documentation, as it's great reference material for learning how they are structured:

https://en.wikipedia.org/wiki/Cron

  • This may be a system crontab, so the ? would refer to the username under which the job will run, and the final * is the command to run – roaima Sep 11 '15 at 16:10
  • 1
    Quite possibly, but due to the nature of the ? and the * being typical syntax of the cron time scheduling elements, I spoke purely with that pretence. As far as I can see though, the question was regarding the ?; meaning my answer should of hopefully provided the insight sought after. – Hugh Sep 11 '15 at 16:19
  • Sorry, I seemed to of misread it initially, as the question was also seeking guidance on the forward slash too; not just the question mark. Fortunately it's also covered in my answer. – Hugh Sep 11 '15 at 16:47

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.