Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: How to save a crontab???

  1. #1

    Default How to save a crontab???

    In Konsole, I type:
    Code:
    sudo crontab -e
    then I had created a new crontab,
    Ex:
    Code:
    30 00 * * * shutdown -P 3 "shutdown"
    but I couldn't save new crontab???
    Can you help me???
    Thanks

  2. #2

    Default Re: How to save a crontab???

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Why couldn't you save? What did you try? You're in 'vi' most likely so
    just hit 'escape' and then the following:

    :wq

    Once done it should be saved. You can also use the following instead of :wq:

    ZZ

    Good luck.





    quangtrung1789 wrote:
    > In Konsole, I type:
    >
    > Code:
    > --------------------
    > sudo crontab -e
    > --------------------
    >
    > then I had created a new crontab,
    > Ex:
    >
    > Code:
    > --------------------
    > 30 00 * * * shutdown -P 3 "shutdown"
    > --------------------
    >
    > but I couldn't save new crontab???
    > Can you help me???
    > Thanks
    >
    >

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v2.0.9 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

    iQIcBAEBAgAGBQJKoAYQAAoJEF+XTK08PnB5edoQAKLRkzZhPduVDDXLinAY+0Px
    YXwx357UsmmyClVRGkdVaiBj1tBfFSITkBIVRBBUApmuRlMfFZ7eiUVYzPXp0v9P
    1LjJ5us6TIX9t+JGrYmze7pU6ae0MeuRRYMkGdRqlo/YBABZHu+XZ5yESXqzZrNr
    CKpeodj0hscw1ojcLvCU/DEhuHjhUk+WSJo6yaNk1nQD4Dub05r++wlI2f5J/9zY
    f8jycwaOMZw3iLM23k+deRH2kLDsdT7CcjW70BShtsXA4c1IsLctX6Yhu6cSRWFi
    M/5PAQlzHLywbcoMspHuF62ddREVeMq75O9CIFJOqufk7bDlQpzUa1A5OCvg4hXP
    NRphT6AZIeiPnO+EZAly5jZkWIXQwQeYgGJXAzl4czfS6AjaEpHJ7enpljIfn6mz
    TwgKXwc8t8qiEpkF3MVMEfUQifTePAImihX0eNkPOD1cFXzBvl2pVs3sLyfk7PwA
    Ybkm5ocxR+M47aLTvaq09o1YvGPQhQgsX/pJgxP2uxKXuW2sbDe4ouTvD0R3yIt2
    ysTjYHBhku/t1c3tnIQwDI0ZxXd3UZLRbBoDJTyi/lQMWgLBW9DynkAzKXSC48Xo
    Ebe2/pie/F3pV00l+ltla7pd4a6fU1ncWvSYAW2cGqoNZ6EH6AhKVxByXUcViG5m
    Mh/QHA9vVHKtw0v0glCF
    =9/jU
    -----END PGP SIGNATURE-----

  3. #3

    Default Re: How to save a crontab???

    The way I have always created/edited crontabs was to create a file with the crontab information using any editor, such as vi. Save the file and then type

    crontab <filename>

    where <filename> is the path/name of the file you created. That will "compile" the entries into the cron table.

    I'm currently at a hp/ux machine, but I'm assuming it's similar on linux. According to the man page, the crontab files are located in /var/spool/cron/crontabs. The name of your crontab (which is what you're attempting to edit by using the -e parameter) is essentially your username.

    My guess is that if you're unable to save, you may not have "write" privileges on the file. You may want to su to root and then try it. I've found that "sudo" does not give you full root privileges. It only allows you to execute certain commands. Therefore, sudo will allow you to run the crontab command, but it doesn't give you extra privileges on files or directories. In those cases you will have to use su rather than sudo.

  4. #4

    Default Re: How to save a crontab???

    The crontab editor is "vi" by default so to exit hit "escape" and then "ZZ".

    I'm confused, how did you manage to insert text without knowing any "vi" commands?

  5. #5

    Default Re: How to save a crontab???

    Quote Originally Posted by pontke View Post
    My guess is that if you're unable to save, you may not have "write" privileges on the file. You may want to su to root and then try it.
    That creates problems. 'crontab -e' edits the crontab of the user who invokes it.

  6. #6

    Default Re: How to save a crontab???

    Sorry... that may be true. I've never used -e

  7. #7

    Default Re: How to save a crontab???

    Quote Originally Posted by pontke View Post
    Sorry... that may be true. I've never used -e
    I quite like the way you suggested, which I didn't know about.

  8. #8

    Red face Re: How to save a crontab???

    oh, I don't really understand what you show
    can you give me a example, I think I will understand more
    Thanks

  9. #9
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,804

    Default Re: How to save a crontab???

    Again.
    When you use crontab -e you are editing using an editor called vi (or vim in its latest incarnation).

    You then type i which is the command to enter insert text mode.
    You then type your text (the crontab entry in this case).
    Then you hit the Esc key to leave text mode.
    Now you type a : This : will show in the lower left hand corner of the terminal emulator.
    Now you finish with the characters wq and Return, this will write to disk and quit vi.

    HTH.

    And try to find some information about vi/vim. It is not the user friendliest editor (to make an understatement), but some knowledge comes handy doing basic sysadmin work like this.
    Henk van Velden

  10. #10
    Join Date
    Mar 2008
    Location
    Oz
    Posts
    11,731
    Blog Entries
    2

    Default Re: How to save a crontab???

    The crontab file requires the last line to be a blank line or else it won't save. Did you add a blank line?
    Leap 42.3 & 15.1 &KDE
    FYIs from the days of yore

Page 1 of 2 12 LastLast

Posting Permissions

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