Cronjob entry in crontab -e vs / etc / crontab. Which one is better?

What is the difference when I insert a crontab entry in crontab -e (the default is: / var / spool / cron / username) and in / etc / crontab? I mean, the crond daemon will do both cron jobs. Then why are there two different ways to schedule a cronjob? Which one is preferable to the other?

+4
source share
1 answer

The difference is that the command crontabis an interface provided by the system for users to manipulate their crontab. The file /etc/crontabis a special case file used to implement a system-wide crontab. /var/spool/cron/crontabs/$USER(or whatever happens the way) is a detail of the implementation.

If you can schedule tasks with a team crontab, you must do this.

Manually editing content /etc/crontab(a) requires root access, and (b) is more error prone. You can mess up your system this way.

If tasks are to be run under your own user account, there is no need to use root access.

root, , crontab. (-, .)

crontab -e. crontab, , crontab filename . , - , .

+9

Source: https://habr.com/ru/post/1530276/


All Articles