Do spaces matter in a crontab

Yes extra space is allowed and you can nicely line up your fields for readability. From man 5 crontab

Blank lines and leading spaces and  tabs  are  ignored.

and

An environment setting is of the form,

   name = value

where the spaces around the equal-sign (=) are optional, and any  sub‐
sequent non-leading spaces in value will be part of the value assigned
to name.

For the fields itself the man pages says:

The fields may be separated  by  spaces or tabs.

That should be clear: multiple spaces are allowed.


Yes Extra whitespace is permitted. Consider:

#Mins  Hours  Days   Months  Day of the week
10     3      1      1       *       /bin/echo "I don't really like cron"
30     16     *      1,2     *       /bin/echo "I like cron a little"
*      *      *      1-12/2  *       /bin/echo "I really like cron"

I always add column headers because I'm too lazy to remember the order of all the numbers, but here's what that crontab produces:

This crontab should echo "I really like cron" every minute of every hour of every day every other month(Every Even month). Obviously you would only do that if you really liked cron. The crontab will also echo "I like cron a little" at 16:30 every day in January and February. It will also echo "I don't really like cron" at 3:10 on the January 1st.

Tags:

Cron