I am trying to get to grip with cron jobs on ubuntu.
I am not sure of the difference between
sudo crontab -e
and
sudo vim /etc/crontab
I assume they both create cron jobs which run under root?
However they give me different files.
sudo vim /etc/crontab
gives me /etc/crontab I think, which is the system wide cron responsible for run-parts and execution of cron.daily etc.
I assume therefore that
sudo crontab -e
creates a personal crontab under /var/spool/cron/crontabs (as per any other user crontab)? But sudo makes it operate under root privileges and associates the crontab to the root user?
Is this correct?
i
When editing
/etc/crontab
or creating a file under/etc/cron.d
,/etc/cron.daily
etc. you are free to choose the user which should run the command. These files should be editable by root only. The file format is:When you use the
crontab -e
command you can't specify the user which runs the command. It is the user which executescrontab -e
. The syntax is simply:IMHO it makes no sense to use
crontab -e
as root. Please checkman 1 crontab
. It gives a proper explanation.