I did edit /etc/crontab using corntab -e.
After save contab is not created despite the message.
To be honest I have no idea what to do. I simply want to create a simple daily job.
Second question. How can I change the editor for crontab -e
?
The command crontab -e
does not edit the system-wide crontab file /etc/crontab
, it edits a user-specific file in /var/spool/cron/crontabs
. The editor used may be changed using the EDITOR
or VISUAL
environment variable ex.
EDITOR=/bin/nano crontab -e
You can confirm that you changes have installed by listing the crontab file, using crontab -l
.
If you want to place your job in /etc/crontab
instead, you would edit it like any other system file ex.
sudoedit /etc/crontab
or (to use the nano
editor explicitly)
sudo nano /etc/crontab
but remember that the format of this file is slightly different - in particular, because the file is not user-specific it requires an additional (sixth) field containing the username under which to run each job.
crontab -e
doesn't edit the system-wide/etc/crontab
file - it edits user-specific files in/var/spool/cron/crontabs
. Do you see your changes if you typecrontab -l
?sudo select-editor
sudo
. Then the preference is set for the current user only. However, that is a different question and does not belong in this question