1

I did edit /etc/crontab using corntab -e.

I have only one entry enter image description here

After save contab is not created despite the message.

enter image description here

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?

10
  • 2
    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 type crontab -l? Apr 9, 2021 at 11:39
  • Change editor with sudo select-editor
    – codlord
    Apr 9, 2021 at 11:40
  • @codlord without the sudo. Then the preference is set for the current user only. However, that is a different question and does not belong in this question
    – vanadium
    Apr 9, 2021 at 11:46
  • 3
    Does this answer your question? Where is the user crontab stored?
    – pLumo
    Apr 9, 2021 at 11:47
  • crontab -l shows me my crontab. Will it run even if I am not logged in? Apr 9, 2021 at 11:50

1 Answer 1

2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .