How To: Set Date and Time On Linux

Jauhari

4 comments

Link

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 😀

Share:

Related Post

4 responses to “How To: Set Date and Time On Linux”

  1. ferdhie Avatar

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

  2. Arief Fajar Nursyamsu Avatar

    Mmm.. thanks for the tip. I’ll try it soon.
    Thanks Bro..

  3. Anonymizer Avatar

    heheh its a nice simple tip for linux users thank any way 🙂

  4. massol Avatar

    Mas Jauhari, Matur suwun (thank you)

    I recently had to change my ubuntu server time.
    Another way to change the time can see here:

    http://codeghar.wordpress.com/2007/12/06/manage-time-in-ubuntu-through-command-line/

    hopefully useful

Leave a Comment