Find the answer to your Linux question:
Results 1 to 5 of 5
Anyone know how to use crontab properly? When I edit my crontab, using "crontab -e", I get stuck inside crontab and I am unable to leave it. I used Google ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2012
    Posts
    19

    [Ubuntu] crontab...


    Anyone know how to use crontab properly?

    When I edit my crontab, using "crontab -e", I get stuck inside crontab and I am unable to leave it. I used Google and there was nothing useful that came about, which surprised me.

    Anyone know how to save and exit? Please be as specific as possible.

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,382
    My guess is, you are just unfamiliar with the vi editor.
    This is the default editor started by crontab -e

    Either learn vi(m), or set a different $EDITOR variable,
    To try it in your current session, type:
    Code:
    EDITOR=nano crontab -e
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Sep 2012
    Posts
    19
    Quote Originally Posted by Irithori View Post
    My guess is, you are just unfamiliar with the vi editor.
    This is the default editor started by crontab -e

    Either learn vi(m), or set a different $EDITOR variable,
    To try it in your current session, type:
    Code:
    EDITOR=nano crontab -e
    So... how do you save and exit?

  4. #4
    Linux Engineer
    Join Date
    Apr 2012
    Location
    Virginia, USA
    Posts
    888
    In nano, the shortcut keys should be at the bottom.

    To save, you want to "Write out" which I believe is ctrl+w
    Then, it will ask you something about "write to file such and such?" and confirm.
    Then, exit with ctrl+x.

    I prefer using vi/vim. To write in vi is to return to command mode, and type :w (then press enter)
    To quit, type :q (then press enter).

    vi/vim takes some time getting used to. It would be worth your time to read a tutorial somewhere online. I vastly prefer vi/vim over nano because bsd, solaris, and many distros don't include nano by default, and vi is on nearly every distro.

  5. #5
    Just Joined!
    Join Date
    Feb 2013
    Posts
    2
    Use this as a quick reference for VI, you will find it useful as VI is the default editor in all Unix platform. You can do fine by knowing 5-6 keyword command.

    ESC = exit command mode or abort an entered mode
    : = enter command mode
    :w = write file
    :q = exit file
    :wq = write and exit file
    :q! = force quit (the ! mean to force the command even if there is a warning, it cannot override OS error like read only file that you try to write etc.)
    :wq! = force write and force quit *just adding the ! symbol*
    :set number = display row line number

    There is type of command that are entered without the : and are editing command shortcut. When you enter one of the editing mode, you have to ESC to exit it and be able to enter another command.

    i = Insert (The cursor will be put exactly where you are, you cannot go beyond the last character. Once in insert mode, what you type is going in the text file as you would with any text editor, to exit press ESC once)
    a = Append (The cursor will be put after the current character, useful if you want to add a character after the last character of the current line)
    s = Suppress the current character and enter Insert mode. The cursor will delete the current character and will be put in editor mode.
    dd = Delete the whole current line
    dw = delete the next word
    123gg = [123 is any number] goto line 123
    DEL key = Delete
    BackSpace = Delete backward


    With that, you can do 90% of the job fast and efficiently.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •