大网数据广告活动
服务器运维问答

Intent of cron.d vs root's crontab

· 52CE 我爱测

In an amazing display of pedantry, a coworker and I have been arguing for literal days over the intended use of the various places for a crontab to live. At the heart of the matter is a backup script we use to push archives to ou…

问题原文

原帖链接 · John Jones · CC BY-SA 3.0

In an amazing display of pedantry, a coworker and I have been arguing for literal days over the intended use of the various places for a crontab to live.

At the heart of the matter is a backup script we use to push archives to our customers of their data. Some want that weekly and others want it exactly on certain day of every month - so our current crontab is pretty lengthy. The utility itself is nothing exotic, just a little node script that gets triggered periodically with different sets of customer-ids passed to it.

With all of them being functionally equal, what is the most correct place for a utility to place its crontab?

  • In root users personal table (sudo crontab -e)
  • In /etc/crontab or /etc/cron.d

TL:DR; What is the intended use of the various cron locations? And where should the schedule for a utility that needs to run without human interaction go?

已采纳解答

原帖链接 · user9517 · CC BY-SA 3.0

As this is a job that is a functiion of the system I would say use a system crontab. As to which one, I don't think there is really any distinction and I've not seen any direction, even the FSH has little to say. On a CentOS 7 system I have to hand man crontab(5) says

Jobs in /etc/cron.d/
The jobs in cron.d and /etc/crontab are system jobs, which are used usually for more than one user, thus, additionaly the username is needed. MAILTO on the first line is optional.

I would use /etc/cron.d

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-03-09)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。