Shell script to update time on Linux server with a time server
You can use Linux command “rdate -s” to set your server’s time. rdate connects to an RFC 868 time server, e.g., time.nist.gov, over a TCP/IP network, printing (-p) the returned time and/or sets (-s) the system clock. You can also use UDP protocol (-u) as the transport.
Then you can use “hwclock –systohc” to set the Hardware Clock to the current System Time.
You can also use a cronjob to update server time periodically:
Tags: Linux
#!/bin/sh
/usr/bin/rdate -s time.nist.gov
/sbin/hwclock --systohc