Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: date and time automaticly

  1. #1

    Default date and time automaticly

    hi,

    i have created a script "datetime":

    #/bin/sh
    ntpdate de.pool.ntp.org

    and put it in /etc/cron.hourly but it is not working. seems like it has never run.

    any ideas what i can do to?

    BiLL

  2. #2
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,683
    Blog Entries
    4

    Default Re: date and time automaticly

    That's the wrong format for a crontab file. It should be something like this:

    Code:
    14 * * * * root ntpdate -s de.pool.ntp.org
    i.e. 14 minutes past every hour, and you should put it in /etc/cron.d so that it isn't wiped out when you upgrade the system, as cron.hourly is for system crontabs. cron.d is for local mods.

    The -s is so that the output goes to syslog instead of stdout and getting emailed to root.

    Better still, if you have an always-on connection is to set up a local NTP server to keep sync with NTP masters. There's a YaST tool to configure that.

  3. #3
    ab@novell.com NNTP User

    Default Re: date and time automaticly

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

    Show the cron entry in its entirety. Also does this work when run
    manually? Do you have any other NTP clients running because, if so,
    you'll want to add a '-u' option into the ntpdate command.

    Good luck.





    BiLL TuEr wrote:
    | hi,
    |
    | i have created a script "datetime":
    |
    | #/bin/sh
    | ntpdate de.pool.ntp.org
    |
    | and put it in /etc/cron.hourly but it is not working. seems like it has
    | never run.
    |
    | any ideas what i can do to?
    |
    | BiLL
    |
    |
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFIhs4Q3s42bA80+9kRAhrkAJ4/jKI0yMaP9Q4wmoFdIWFqXE0uqwCfXEKV
    eglenZ+6/+feUHvlpBzd9nA=
    =7Faw
    -----END PGP SIGNATURE-----

  4. #4

    Default Re: date and time automaticly

    so, you mean i just have to create a file with that entry and put it in cron.d?

    14 * * * * root ntpdate -s de.pool.ntp.org

    is that right?

  5. #5
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,683
    Blog Entries
    4

    Default Re: date and time automaticly

    That's right, call it something like ntpsync. And ab@novell.com is correct, if you have a NTP server running you should add the -u flag, although if you have a NTP server running, you wouldn't need this job.

  6. #6

    Default Re: date and time automaticly

    hehe, sorry. seems like my script was not executable by no one

    greetz

  7. #7
    ab@novell.com NNTP User

    Default Re: date and time automaticly

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

    Well, the command ken yap posted should be put in something like
    /etc/crontab directly. Your script should go in /etc/cron.hourly and
    then run properly. Have you tested it yet on its own? How do you know
    it is not working? Any reason you don't use the NTP client built into SUSE?

    Good luck.





    BiLL TuEr wrote:
    | so, you mean i just have to create a file with that entry and put it in
    | cron.d?
    |
    | 14 * * * * root ntpdate -s de.pool.ntp.org
    |
    | is that right?
    |
    |
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFIhtQH3s42bA80+9kRAqokAJ0U1iZILTvUBEUSBMmB+42aIouKNQCdEuwM
    17q+b6scl8mtvers5kcmv5o=
    =siRX
    -----END PGP SIGNATURE-----

  8. #8

    Default Re: date and time automaticly

    i have tested it manualy and checked that the file was not executable. now it should work. in one hour i will have a look in syslog to see if it works now.

    i did it my way and put the file in /etc/cron.hourly.

    greetz

  9. #9
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,683
    Blog Entries
    4

    Default Re: date and time automaticly

    Quote Originally Posted by ab@novell.com View Post
    Well, the command ken yap posted should be put in something like
    /etc/crontab directly. Your script should go in /etc/cron.hourly and
    then run properly.
    No, there's a reason for /etc/cron.d/, it's for local cron jobs, whereas /etc/crontab and /etc/cron.hourly/ and /etc/cron.daily/ are for preinstalled cron jobs, which get deposited by various packages. That's the convention. And anyway /etc/cron.d/ gives you more flexibility than the others. You can specify the user in contrast to /etc/crontab which is always root, and you can specify the exact time and repetition (even things like every Sunday, or every two hours) instead of once an hour some minute like /etc/cron.hourly/ and once a day sometime like /etc/cron.daily/.

    Also note that the format required in /etc/crontab is without the 6th field (user) as it is always run by root, see above.

  10. #10
    ab@novell.com NNTP User

    Default Re: date and time automaticly

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

    The system crontab (/etc/crontab) also takes a username as the sixth
    string in a line so it too has the same functionality as /etc/cron.d
    though using the directory is probably advised for the other reasons you
    mentioned.

    man 5 crontab

    Good luck.





    ken yap wrote:
    | ab@novell.com;1844030 Wrote:
    |> Well, the command ken yap posted should be put in something like
    |> /etc/crontab directly. Your script should go in /etc/cron.hourly and
    |> then run properly.
    |
    | No, there's a reason for /etc/cron.d/, it's for local cron jobs,
    | whereas /etc/crontab and /etc/cron.hourly/ and /etc/cron.daily/ are for
    | preinstalled cron jobs, which get deposited by various packages. That's
    | the convention. And anyway /etc/cron.d/ gives you more flexibility than
    | the others. You can specify the user in contrast to /etc/crontab which
    | is always root, and you can specify the exact time and repetition (even
    | things like every Sunday, or every two hours) instead of once an hour
    | some minute like /etc/cron.hourly/ and once a day sometime like
    | /etc/cron.daily/.
    |
    | Also note that the format required in /etc/crontab is without the 6th
    | field (user) as it is always run by root, see above.
    |
    |
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFIhtpv3s42bA80+9kRAn59AKCIjNDFyFWvffFAXmpFvG+d31auwgCgiGHG
    s3aAk/KtzW6DPa5qG283GJQ=
    =A6mP
    -----END PGP SIGNATURE-----

Page 1 of 3 123 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
  •