What is the difference between cron.d (as in /etc/cron.d/) and crontab?
The differences are documented in detail in the cron(8)
manpage in Debian. The main difference is that /etc/cron.d
is populated with separate files, whereas crontab
manages one file per user; it’s thus easier to manage the contents of /etc/cron.d
using scripts (for automated installation and updates), and easier to manage crontab
using an editor (for end users really).
Other important differences are that not all distributions support /etc/cron.d
, and that the files in /etc/cron.d
have to meet a certain number of requirements (beyond being valid cron jobs): they must be owned by root, and must conform to run-parts
’ naming conventions (no dots, only letters, digits, underscores, and hyphens).
If you’re considering using /etc/cron.d
, it’s usually worth considering one of /etc/cron.hourly
, /etc/cron.daily
, /etc/cron.weekly
, or /etc/cron.monthly
instead.
I would say the main difference is the obvious one: /etc/crontab
and /etc/cron.d
are not modifiable by regular users, while the per-user crontabs in /var/spool/cron
that the crontab
tool edits, are. (Subject to cron.allow
and cron.deny
, of course.) Of course on a system where you are the administrator, you could use either. On a shared system, the regular users can only use one.
Related to this is the extra field in the system-wide files, the username under which the job runs.