A friend of mine asked me, because his machine is having bad CMOS battery and on every reboot, his machine claims we are January 1970 😀
Cute. Obviously, I wasn’t born yet, when he had this web server 😀
This is what you must do to synchronize your clock:
bash-4.1# ntpdate 0.pool.ntp.org 2 Jun 11:08:57 ntpdate[3110]: step time server 94.26.7.48 offset -13.078094 sec bash-4.1# hwclock --systohc bash-4.1#
As simple as it is. 2 commands. Of course, if you have an NTP server closer to you than ntp.org. Feel free to use other server.
If you want this to be done in one script, that’s started as user, you may set it this way:
bash-4.1# touch SyncClock.sh bash-4.1# cat > SyncClock.sh #!/usr/bin/bash echo "Clock is syncing to NTP, please wait..." sudo /usr/sbin/ntpdate 0.pool.ntp.org sudo /sbin/hwclock --systohc ^D bash-4.1# chmod +x SyncClock.sh
Of course, this user should have passwordless sudo 😉 which I don’t really recommend.
And with this script in mind, if you want your timer synchronized every reboot, put it to /etc/rc.d/rc.local:
bash-4.1# echo -e "\n#Clock sync script\n/root/scripts/SyncClock.sh" >> /etc/rc.d/rc.local
Or even better, put it to cron, so it’s synchronized daily.
bash-4.1# cp /root/scripts/SyncClock.sh /etc/cron.daily
That’s really all you could need.
3 Responses to “How to synchronize your Slackware Linux’ clock”
Sorry, the comment form is closed at this time.
tnx
Awesome! Thank you very much.
Yep. I now know how to respond to daylight savings time. Thanks!