Until now I have been always using Debian in my servers while Arch Linux as my Desktop and Laptop’s operating systems.
A week ago I decided to run Arch Linux in one of my servers, and yes, there are some differences, for instance Apache, where even the name of the daemon is different (Apache2 in Debian and httpd in Arch Linux).
But the one that really made me investigate a little more was cron daemon, they not only have differences they are different programs in each distribution, of course you can install either on Debian or Arch the version the other one comes with as default. Arch Linux comes with Dillon’s Cron, while Debian (I think) comes with Dixie Cron please let me know if I am wrong.
The syntax these two versions support is slightly different, and here are both Debian Cron and Arch Cron support pages for cron and their syntax, another good resource for Debian like syntax is the Crunchbang Linux Cron help page.
I used to program cron jobs this way (It works on Debian).
- Create a file in the
/etc/cron.d/directory as root
- Put there the commands I wanted to run using this syntax
minute hour dom month dow user cmd minute This controls what minute of the hour the command will run on, and is between '0' and '59' hour This controls what hour the command will run on, and is specified in the 24 hour clock, values must be between 0 and 23 (0 is midnight) dom This is the Day of Month, that you want the command run on, e.g. to run a command on the 19th of each month, the dom would be 19. month This is the month a specified command will run on, it may be specified numerically (0-12), or as the name of the month (e.g. May) dow This is the Day of Week that you want a command to be run on, it can also be numeric (0-7) or as the name of the day (e.g. sun). user This is the user who runs the command. cmd This is the command that you want run. This field may contain multiple words or spaces.
I usually run cron jobs as different users and not as root, to avoid security problems.
Now that I am using Arch in one of my servers this is not supported anymore as Dillon’s Cron’s syntax is easier, and does not support env variables.
So the way I have to do it now is:
- Login as the user I want to run the cronjob
- Enter the command:
- Use this syntax
minute hour day_of_month month day_of_week command * minute values can be from 0 to 59. * hour values can be from 0 to 23. * day_of_month values can be from 1 to 31. * month values can be from 1 to 12. * day_of_week values can be from 0 to 6, with 0 denoting Sunday.
You may also want to read this article