Archive for the tag 'Time'

SBDavid

Linux Network Time Protocol Setup

Linux Network Time Protocol Setup

We can also synchronize the system clock with a remote server over the Network Time Protocol ( NTP).

For the one-time synchronization only, use the ntpdate command:

Check whether the selected NTP server is accessible:

[root@fedora ~]# ntpdate -q 0.rhel.pool.ntp.org
server 202.71.136.67, stratum 2, offset 0.014709, delay 0.25420
server 119.226.101.130, stratum 2, offset -0.007991, delay 0.21991
3 Oct 09:40:35 ntpdate[4083]: adjust time server 119.226.101.130 offset -0.007991 sec
[root@fedora ~]#

Run the ntpdate command followed by one or more server addresses:

[root@fedora ~]# ntpdate 0.rhel.pool.ntp.org 1.rhel.pool.ntp.org
3 Oct 09:41:36 ntpdate[4092]: adjust time server 119.226.101.131 offset 0.000724 sec

Enable the service.

[root@fedora ~]# systemctl status ntpd.service
ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled)
Active: inactive (dead) since Wed, 03 Oct 2012 09:42:42 +0530; 36s ago
CGroup: name=systemd:/system/ntpd.service

Oct 03 09:42:42 fedora.example.com ntpd[4105]: ntpd 4.2.6p5@1.2349-o Fri Apr 27 08:37:16 UTC 2012 (1)

SBDavid

Date and Time Setup

Date and Time Setup

The date command allows the superuser to set the system date and time manually:

Change the current date.

Type the command in the following form at a shell prompt, replacing the YYYY with a four-digit year,
MM with a two-digit month, and DD with a two-digit day of the month:

For example, to set the date to 2 June 2010, type:

# date +%D -s 2010-06-02

Change the current time. Use the following command, where HH stands for an hour,
MM is a minute, and SS is a second, all typed in a two-digit form:

For instance, to set the system clock to 11:26 PM using the UTC, type:

# date +%T -s 23:26:00 -u

You can check your current settings by typing date without any additional argument:

# date
SBDavid

Time Synchronisation with NTP

Time Synchronisation with NTP

NTP is a TCP/IP protocol for synchronising time over a network. Basically a client requests the current time from a server, and uses it to set its own clock.

Behind this simple description, there is a lot of complexity - there are tiers of NTP servers, with the tier one NTP servers connected to atomic clocks (often via GPS), and tier two and three servers spreading the load of actually handling requests across the Internet. Also the client software is a lot more complex than you might think - it has to factor out communication delays, and adjust the time in a way that does not upset all the other processes that run on the server. But luckily all that complexity is hidden from you!

Linux Distros has two ways of automatically setting your time: ntpdate and ntpd.

ntpdate as standard, and will run it once at boot time.

The ntp daemon ntpd is far more subtle. It calculates the drift of your system clock and continuously adjusts it, so there are no large corrections that could lead to inconsistent logs for instance.

You can change the time zone within a php script. Here is a sample code:

With the php tags enter the following

putenv(”TZ=Europe/Amsterdam”);

You can set the timezone in .htaccess as well. Add the line:

SetEnv TZ America/Indianapolis

List of timezones is here: http://us.php.net/manual/en/timezones.php

SBDavid

How to Change Date and Time

How to Change Date and Time

You can change the date and time on linux machine using the date command.

Example: If you want to change the date to July 31, 11:16 pm then type as follows

date 07312316

If you want to change the year as well, you could type

“date 073123161998”

You can also use the following:

date -s “31 JULY 2009 23:16:00″