0

I have Ubuntu 16.04. From here Run Scripts on Start UP. I followed this answer:

One approach is to add an @reboot cron task:

Running crontab -e will allow you to edit your cron. Adding a line like this to it:

@reboot /path/to/script

will execute that script once your computer boots up.

I was successfully able to edit file crontab.

but I couldn't be able to save it using:

  • :q
  • :wq
  • CTRL+x

None of them worked. I got this message on command :q:

No write since Last Change (add ! to override
  • After executing command - EDITOR=vi crontab -e

    Output - no crontab for admin - using an empty one

  • Again on executing command - sudo EDITOR=vi crontab -e

    Output - no crontab for root - using an empty one

Zanna
  • 70,465

2 Answers2

1

You have done well so far. The No write since Last Change(add ! to override) means you have written something and are closing without saving so the editor assumes you don't wish to save your changes and offers you the option of doing so with :q!. Now you need to use :wq to ensure that the changes are written then the editor is quit or exited.

Where its a nano editor as I noticed crontab uses this please do the following:

  1. To save: Ctrl+o, then press Enter

  2. To close: Ctrl+x

George Udosen
  • 36,677
0

Having a cron job that causes an unexpected, immediate reboot could cause you frustration and confusion.

If you are convinced that you want to do this, the command to write and exit the editor depends on what editor you selected when you invoked the crontab -e command.

Esc :wq! or Shift ZZ will work for vi

For nano, Ctrl O followed by Ctrl X

jones0610
  • 2,157