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?

0___________
  • 113
  • 3
  • 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`? – steeldriver Apr 09 '21 at 11:39
  • Change editor with `sudo select-editor` – codlord Apr 09 '21 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 09 '21 at 11:46
  • 3
    Does this answer your question? [Where is the user crontab stored?](https://askubuntu.com/questions/216692/where-is-the-user-crontab-stored) – pLumo Apr 09 '21 at 11:47
  • crontab -l shows me my crontab. Will it run even if I am not logged in? – 0___________ Apr 09 '21 at 11:50
  • It will run when the computer is switched on, your login is not necessary, but your `backupshare` ***might*** not be mounted which would cause the command to fail. – pLumo Apr 09 '21 at 11:51
  • It is my local server running gitlab. Need to delete gitlab backup files :)(. One week backup is enough for me – 0___________ Apr 09 '21 at 11:52
  • @pLumo is there any way to see if my command was executed correctly? – 0___________ Apr 09 '21 at 12:01
  • check https://askubuntu.com/questions/56683/where-is-the-cron-crontab-log – pLumo Apr 09 '21 at 12:05
  • @steeldriver You should probably post your comment as answer. – raj Apr 09 '21 at 12:28

1 Answers1

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.

steeldriver
  • 131,985
  • 21
  • 239
  • 326