linux server Automatic time update
Automatic time update
If you have a server that day and night to run if you do not always check that your system still displays the correct time. With the script you can set each day your server is the system clock update.
This tweak is applied to any Linux distribution, using cronjobs.
First we make a small file with your favorite text editor and type the following text:
Code:
Quote:
#! / bin / sh
ntpdate pool.ntp.org
And stores it in eg / usr / local / bin as update_
time.
This file must then be made executable:
Code:
Quote:
$ chmod + x update_
time
Then go to / etc and open the crontab file (must be root / super user).
As you add the following line under # run-parts:
Code:
Quote:
# Run-parts
0 4 * * * root / usr / local / bin / update_time
This file in turn.
The five positions (0 4 * * *) for 'root' to where you want the script is executed:
Code:
Quote:
0 / / The 1st position indicates the minute of the time the script is executed
4 / / The second digit indicates the hour (ie at 4 am)
* / / The third on the day of the month (* = any day of the month)
* / / The fourth which month (* = any day of the month)
* / / The fifth position indicates the day of the week (* = any day of the week)
In other words, this code ensures that every night at 04:00 pm the script to the location / usr / local / bin / update_
time is executed by user root. If you are sure that your server every day at the time
Re: linux server Automatic time update
rdate [-p] [-s] [-u] [-l] [host...]
rdate connects to an RFC 868 time server over a TCP/IP network, printing the returned time and/or sets the system clock.
OPTIONS
-p
Print time returned by the remote machine.
-s
Set system time to the returned time.
-u
Use UDP instead of TCP as the transport.
-l
Use syslog to output errors (cron.warning) and output (cron.info).
We will use this to set the time.
rdate -s time.nist.gov
There are other servers/hosts that you can retrieve the time from. This is the one we use on the east coast.
or you can use UCLA's