CentOS/Linux crontab?

How do you exit crontab?

I'm using SSH to access the VPS.

I used the command crontab -e

An editor of sorts is visible in SSH.

In the editor I've set the first line as

*/10 * * * * /home/you/znc/bin/znc >/dev/null 2>&1

The problem is, it doesn't let me save & exit, how do I do that?

I've tried CTRL+C, CTRL+D, Pause/break, Shift+pause/break.

Update:

I'm not trying to get root to run the cron.

Anyways ESC doesn't save & exit

Comments

  • Your editor of choice can be defined by the EDITOR environment variable. If you know that you like pico (for example), this will set it for the session:

    export EDITOR=pico

    You can add that (and other lines) to your .profile or .bash_profile file so that it runs each time you log in.

    If the editor is vi, then you need to do what one of the other posters suggested: ESC Z Z (that's three key presses: the Escape key, then two capital Z keys. Or four if you're a pendant and include the Shift key itself). In general, Linux-based systems ignore the Break key, so Pause/break and Shift+Pause/Break won't have any useful effect. You were right to try Ctrl/C - but that at best would have crashed out of the editor rather than saving the file. I can't remember how you get out of emacs, but it's fairly unlikely to be emacs on a default VPS configuration. Most other editors assume you're a novice and provide you with a menu of options or keystrokes.

    Finally, if all you're trying to do is to get that one line into your own crontab, you can do it by just entering "crontab" (plus {enter}, of course), typing the single crontab line, and then hitting Ctrl/D (not Ctrl/C or Ctrl/Z). This is the expert "I know what I'm doing, don't give me an editor, just let me get on with it" mode, also known as the "Oh bother, I've just erased my existing crontab by accident" mode.

  • hello

    Be sure you logged in as root or sudo user

    you can save the crontab by ESC KEY , then press :wq! ( colon w q ! )

    try this ..

Sign In or Register to comment.