5

Let's assume that I want to run a shell script named test.sh at 1 AM every day. I could either use:

0 1 * * * /home/user/test.sh

Or I could use:

0 01 * * * /home/user/test.sh

For the above example, which is technically the correct answer - should a leading 0 be used in the shedule, or should just the number of the hour be entered?

0

2 Answers 2

6

If your cron accepts zero-filled numbers, you may use them.

Since the POSIX specification for crontab and the crontab(5) manual on all systems that I have access to only give examples without zero-filled numbers (without actually saying anything about the formatting of numbers), it may be prudent to stay with non-filled numbers if you at some point find yourself on a system where zero-filled numbers are not accepted.

There are examples of systems where 01 is the same as *, not 1:

1

In https://github.com/vixie/cron I see that entry.c::get_number() just calls atoi(3) which has no special behavior in the case of leading zeros. It seems possible that some atoi(3) somewhere will treat a leading zero as introducing octal (base 8) rather than decimal (base 10). I would be surprised if any fork of Vixie Cron behaved otherwise.

You must log in to answer this question.

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