NTP or network time protocol is a protocol that will synchronize the time of a computer client or server to another server or reference time source, such as a radio or satellite receiver or modem. Typical NTP configurations utilize multiple redundant servers and diverse network paths in order to achieve high accuracy and reliability.
Follow the below setup to install your ntp server:
1. install ntp: $ yum install -y ntp
2. edit ntp.conf: $ vi /etc/ntp.conf
example of ntp.conf:
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.rhel.pool.ntp.org
#server 1.rhel.pool.ntp.org
#server 2.rhel.pool.ntp.org
#server mst.sirim.my prefer
#server my.pool.ntp.org
#broadcast 192.168.1.255 key 42 # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 key 42 # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 key 42 # manycast client
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
#server mst.sirim.my prefer
#server my.pool.ntp.org
# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntp/drift
# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# Specify the key identifiers which are trusted.
#trustedkey 4 8 42
# Specify the key identifier to use with the ntpdc utility.
#requestkey 8
# Specify the key identifier to use with the ntpq utility.
#controlkey 8
3. If the server you are setting up do not have internet connection, you can synchronize it with the local time of the server itself. Just comment the server part, and change it to 127.127.1.0. The sratum level is for determining what level this time server is set up for. Stratum 0 usually refers to real clock, for example atomic (cesium, rubidium) clocks or GPS clocks or other radio clocks. Stratum 1 is the machine connected to stratum 0 devices.
#server mst.sirim.my prefer
#server my.pool.ntp.org
server 127.127.1.0
fudge 127.127.1.0 stratum 10
4. synchronize the server's time with the ntp server: $ ntpdate -du mst.sirim.my
5. start ntp service: $ /etc/init.d/ntpd start
In the client machine, just type: $ ntpdate -du ntpservername. You can also put this command in crontab for the client to be update frequently
Thursday, August 23, 2007
Setting up your own ntp server
Thursday, August 2, 2007
Installing lighttpd in Centos 5 for x86_64
Lighttpd is a fast and optimized web server that prioritize performance. To install this web server application, some additional work need to be done because there is no rpm compiled version of this web server for x86_64 architecture yet. So we have to do the hard work by getting the spec file, compiling the source and all. Steps to be taken to successfully install lighttpd on Centos 5 x86_64 machine are as below:
- get the rpm source file for lighttpd from here
- install the requirement needed to compile the source: pcre-devel 6.6-1.1, mysql-devel 5.0.22-2.1 and lua-devel. The first two can be be installed from yum: $ yum install -y pcre-devel mysql-devel. The last one can be downloaded from here and its dependencies can downloaded from here. Install the last dependencies using: $ rpm -Uvh lua-5.1.2-1.el5.kb.x86_64.rpm lua-devel-5.1.2-1.el5.kb.x86_64.rpm
- Install the lighttpd rpm source file: $ rpm -Uvh lighttpd-1.4.16-1.el5.src.rpm
- The spec file for lighttpd will be saved into /usr/src/redhat/SPECS
- Compile the spec file: $ rpmbuild -bb /usr/src/redhat/SPECS/lighttpd.spec
- The rpm for lighttpd will be saved into /usr/src/redhat/RPMS/x86_64. Install lighttpd: $ rpm -Uvh /usr/src/redhat/RPMS/x86_64/lighttpd-1.4.16-1.x86_64.rpm
- Check whether your lighttpd has been installed: $ rpm -qa | grep lighttpd If the result is as picture, your lighttpd is installed

Tuesday, July 31, 2007
Using crontab scheduler
Crontab is a tool for scheduling tasks for the computer to run. It will automate the jobs that needs to be done but will be difficult to be done by human because of time limitation. There are only 4 options for crontab which are -u, -e, -l and -r and the usage is described below:
- crontab -l - list all the crontab on standard output
- crontab -e - edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables
- crontab -r - remove the current crontab
- crontab -u - specify the user
- example: $ crontab -u username -l - this command will list the crontab belongs to the username
* * * * * command to be run
1st * is for minutes (0-59)
2nd * is for hour (0-23)
3rd * is for day of month (1-31)
4th * is for month of year (1-12)
5th * is for day of the week (0-7) where 0=Sunday and 7=Sunday
Example:
To backup your pc using rsnapshot everyday at 7.30 a.m.;
- $ crontab -e
- 30 7 * * * /usr/local/bin/rsnapshot daily
- save your crontab setting

Tuesday, July 24, 2007
System backup using rsnapshot
Rsnapshot is a filesystem snapshot utility that we can use for free to backup our system. To use this tool, user must have perl, ssh and rsync installed in their machine. Rsnapshot is an ideal tool for backup because it saves a lot of hard disk space. This can be done because the space needed is roughly the size of one full backup plus a copy of each additional file that is changed. The installation is also simple as shown below:
- install rsnapshot
- -> yum install rcsnapshot
- after installation, do some setting in /etc/rsnapshot.conf . Some of the important settings are as below:
- snapshot_root - change it to your preferred directory
- cmd_cp - for linux user, uncomment this option
- backup script
- backup user@servername:/folder/to/backed-up destination/in/snapshot_root
- interval - set this to set the frequency of snapshot to be taken. Please note that it must be arranged from smaller unit(hourly) on top to bigger one. For example:
- interval daily 7 - this means snapshot will be taken 7 times a week
- interval weekly 4 - this means snapshot will be taken 4 times a month
- Test the validation of the config file
- -> rsnapshot configtest
- Test run your command
- -> rsnapshot -t daily
- To backup, just run the below command(for daily)
- -> rsnapshot daily
Friday, July 20, 2007
Setting system clock and date
To set system clock and date using command, date command can be used.
This is how to do it:
-> date mmddttttyyyy.ss where;
mm - month
dd - day
tttt - time in hours and minutes
yyyy - year
ss - seconds
For example, to set the current date to 17 July 2007, 11:15 a.m., this command below can be used:
-> date 071711152007
To see the current date, the date command without argument can be used.
-> date