Timeline for How are files under /etc/cron.d used?
Current License: CC BY-SA 4.0
20 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 28, 2024 at 18:23 | comment | added | Alan CN |
Escape percent (%) signs that may be used, such as in date commands. They are interpreted as newline characters. This saved me time! Source: stackoverflow.com/a/5474276/2952626
|
|
| Apr 12, 2022 at 4:06 | comment | added | Stephen Kitt | @racitup that‘s right, nothing needs to be restarted or reloaded. | |
| Apr 12, 2022 at 0:07 | comment | added | racitup | Does "are monitored for changes" mean I don't have to restart anything after a modification to cron.d files? | |
| Nov 5, 2021 at 14:01 | comment | added | Loenix | My /etc/cron.d/company does not seem to run */3 * * * * www-data /home/company/path/to/script Running su - www-data -c /home/company/path/to/script is working | |
| Oct 28, 2019 at 22:00 | comment | added | FKEinternet |
Another thing to take note of is files in /etc/cron.d MUST include the user field or they simply will not run - with nothing being logged to indicate what the problem is.
|
|
| Jan 16, 2019 at 19:06 | comment | added | Tino |
People might miss, that "the file names must conform to the filename requirements of run-parts" (see Debian's man cron). So filenames in /etc/cron.d/ which match the shell glob *[!A-Za-z0-9_-]* are ignored! Hence things like *.dpkg-dist or vi-backups *~ do no harm, but if you accidentally create /etc/cron.d/very_important.crontab, this will get ignored due to the . in it!
|
|
| Nov 1, 2018 at 15:12 | comment | added | Stephen Kitt |
crontab -e run as any user will create a user-specific crontab for that user; root is no different. But the way root should be used means there’s not much point in having a root-specific crontab in /var/spool/cron.
|
|
| Nov 1, 2018 at 15:06 | comment | added | Tim |
Thanks. My apology. sudo crontab -e will create /var/spool/cron/crontabs/root, so I thought that that file can be created so must be used for some purpose.
|
|
| Nov 1, 2018 at 15:05 | comment | added | Stephen Kitt | anacron only deals with system jobs, yes. | |
| Nov 1, 2018 at 15:05 | comment | added | Stephen Kitt | A system job is a job which applies to the whole system. A user-specific job is a job run on behalf of a specific user; typically, tasks which the user would do manually while logged in, but which he/she wishes to perform periodically and automatically — e.g. backups of specific files, or refreshes of remote development repositories, or mail processing, or mirroring web sites... | |
| Nov 1, 2018 at 15:03 | comment | added | Stephen Kitt | Please don’t edit comments so radically when they ask questions :-(. | |
| Nov 1, 2018 at 15:02 | comment | added | Stephen Kitt |
As far as I’m concerned, as I said above /var/spool/cron/crontabs is for user-specific jobs. If an admin chooses to use root as a user account, then it would make sense for root’s jobs (the user’s, not the system’s) to go in /var/spool/cron/crontabs/root. But since root shouldn’t be used as a user account, I tend to think that /var/spool/cron/crontabs/root shouldn’t be used either.
|
|
| Nov 1, 2018 at 14:57 | comment | added | Tim |
Thanks. (1) What do "system job" and "user specific job" mean? (2) Is /var/spool/cron/crontabs/root for system jobs? root-specific jobs are system jobs, I guess? (3) anacron by default only runs /etc/cron.{hourly,daily,weekly,monthly}/*, so is anacron used only for system jobs not for user-specific jobs?
|
|
| Nov 1, 2018 at 14:32 | comment | added | Stephen Kitt |
I only ever use /var/spool/cron for user-specific jobs. Any system job should go in /etc/crontab or /etc/cron.{hourly,daily,weekly,monthly} IMO.
|
|
| Oct 31, 2018 at 18:55 | comment | added | Tim |
Thanks. "In general, the system administrator should not use /etc/cron.d/, but use the standard system crontab /etc/crontab." When should a sysadmin use /var/spool/cron/crontabs/root or /etc/crontab?
|
|
| Jul 26, 2018 at 23:59 | comment | added | Stephen Kitt |
“However, they are independent of /etc/crontab”, as quoted above. To be absolutely clear, /etc/crontab doesn’t include files from /etc/cron.d by default. (As an administrator, you could place commands in /etc/cron.d and use them in /etc/crontab, but that would be thoroughly confusing.)
|
|
| Jul 26, 2018 at 23:59 | vote | accept | Tim | ||
| Jul 26, 2018 at 23:55 | history | edited | Stephen Kitt | CC BY-SA 4.0 |
added 272 characters in body
|
| Jul 26, 2018 at 23:53 | comment | added | Tim | Thanks. Are the files in /etc/cron.d and /etc/crontab independent of each other, and read by crond independently and separately? Or does /etc/crontab ever include the files in /etc/cron.d? | |
| Jul 26, 2018 at 23:51 | history | answered | Stephen Kitt | CC BY-SA 4.0 |