Wednesday, August 6, 2008

Time Drift

Recently, I noticed my linux box in the lab is slowly drifting in time. After resetting the time for 2 times, I think I got to do something about it. So, wasting no time, I installed ntp. It's no big deal, and I'm sure a lot of the old-timers in linux are very familiar with this, so this is something for newbies and people wanting to explore the use of linux.

To install, on debian, just use:

$ aptitude install ntp

Then after that, you can start your ntp daemon. To do this, just type, as root:

$ /etc/init.d/ntp start

That should give you the utmost correct time.

Suppose you would like to edit your configuration to use the local time server or a time server in your department. Well, all you need to do is to edit /etc/ntp.conf. I've added these lines to add the server in my department.

server iburst dynamic
server iburst dynamic
server iburst dynamic
server iburst dynamic

and rerun ntp daemon with:

$ /etc/init.d/ntp restart

Now, some of you might be a little curious on the options given to the servers. Well here is an explanation taken from the man page.


When the server is unreachable and at each poll interval, send a burst of eight packets instead of the usual one. As long as the server is unreachable, the spacing between packets is about 16s to allow a modem call to complete. Once the server is reachable, the spacing between packets is about 2s. This is designed to speed the initial synchronization acquisition with the server command and s addresses and when ntpd(8) is started with the -q option.

Now, I can't find a good explanation for dynamic option on the web. But I'm sure since the original .conf file has it, so I'm just going to keep the dynamic option there.

There are people who thinks that we might as well use a ntp-client like ntpdate to synchronize time, however, ntpdate needs to be run manually or by cron. It is however more resource friendly, and only runs when you want it to run, unlike ntp server which would be running as a server all the time. However, there is an issue about time drift. And the problem with ntpdate, it does not have the algorithm to handle time drift. Hence, since I'm a little obsessed about time to the milliseconds, time drifts is an important thing for me, and ntp has the algorithm to calculate the time drift and readjusting time as necessary. :) Hope that helps, comments by experts are highly appreciated to get a better understanding of things, questions are also welcomed.

Monday, August 4, 2008

How to delete a file starting with a character "-"

Recently, I tried to delete a file which has a starting "-". The filename is called --ahlong.avi. Unfortunately, running

$ rm -- --ahlong.avi

gave me an error. So how do you delete a file that has a "-" starting character. Well i found out there are a few ways to do this....

$ rm ./--ahlong.avi
$ rm -- --ahlong.avi

Both seems to work.