How To: Set Date and Time On Linux

A few days ago I need to reconfigure office proxy server (I am using Squid) to avoid certain users accessing Internet during work hour. Sound extreme huh? But it’s a company policy. I can not deny.

They are not allowed to access during 08:00-12:00 and 13:00-16.30. After configuring and apply the ACL (Access Control List)  to my PC for trial, the ACL did not work. I ever did this before. I just did a copy and paste. It should work. Search result on the Internet to find the right configuration convinced me that mine was correct.

It must be caused by another problem, I guessed. It’s true. I did “touch test” and “ls-l” showed that the file was not created in the correct clock time. The “date” command told that the time on the server was not coorect.

I need to adjust server clock setting. Here is the command.

# date -s ‘MM/DD/YYYY HH:MM:SS’ <– change with actual date and time eg: ’12/24/2007 16:25:00′

# clock -w  <– to set the hardware clock (CMOS)  to match the kernel time

# echo “clock -s” /sbin/hwclock  <– to make sure that the time is always correct on reboot, link the kernel time to hardware clock

# chmod +x /sbin/hwclock  <– make the script executable

Voila. The time is adjusted and my ACL worked like a charm.

Now, it’s time to wait for the complain 😀

4 Comments

  1. you could setup an NTP services for synchronizing ur proxy server clock with the time server and forget setting up your server clock.

Leave a Reply

Your email address will not be published. Required fields are marked *