LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-13-2005, 06:21 PM   #1
DJOtaku
Member
 
Registered: Oct 2004
Location: USA
Distribution: Fedora 25;CentOS 7; Kubuntu; Debian
Posts: 860

Rep: Reputation: 36
setting the time in command line


Hey there!

I'm a US member, meaning that the clocks have just been adjusted up one hour since about a week ago. I am running a LAMP server and wanted to know what was the best way to change the time from the command line. I read a few things on google but they talked about UDC time vs time zone vs the computer resetting the time when you reboot. Since this is a public server I really don't want to reboot.

So what commands can I use to check the system time and adjust it ahead by one hour accordingly.

Thank you very much,
 
Old 04-13-2005, 06:23 PM   #2
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
man date
 
Old 04-13-2005, 06:34 PM   #3
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 60
Sometimes the man pages can be a little short on examples, so here is one....

Run the command: date -s "04/13/2005 19:38:00"
 
Old 04-13-2005, 06:47 PM   #4
int0x80
Member
 
Registered: Sep 2002
Location: Cincinnati
Distribution: Debian GNU/Linux
Posts: 310

Rep: Reputation: 31
To set the date, just supply the date in the following format: MMddhhmm (assuming you have the correct year)
So right now, where I live, it's April 13 at 7:46 PM. To set the date I would run:
date 04131946

04 => April
13 => 13th
19 => 7 (PM)
46 => :46 (PM)

HTH
 
Old 04-13-2005, 10:52 PM   #5
DJOtaku
Member
 
Registered: Oct 2004
Location: USA
Distribution: Fedora 25;CentOS 7; Kubuntu; Debian
Posts: 860

Original Poster
Rep: Reputation: 36
Ok, I type in "date" and according to the output, it's already set to the right time. Yet, all of my server programs think it's 1 hour behind. For example, phpBB and Wordpress think it's earlier, but

date gives me Thur 14 Apr 00:10am
 
Old 04-13-2005, 11:38 PM   #6
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 75
You could run nntp and this updates the clock automatically, because your system syncs its time with another server on the internet.
 
Old 04-14-2005, 12:16 AM   #7
DJOtaku
Member
 
Registered: Oct 2004
Location: USA
Distribution: Fedora 25;CentOS 7; Kubuntu; Debian
Posts: 860

Original Poster
Rep: Reputation: 36
don't have nntp -> get a command not found error when running as root. Any other suggestions?
 
Old 04-14-2005, 01:34 AM   #8
jmajor
Member
 
Registered: Nov 2004
Location: Australia
Distribution: Fedora, Ubuntu
Posts: 55
Blog Entries: 2

Rep: Reputation: 17
Generally linux will keep track of time using Universal Mean Time (UMT), sometimes called Greenwich Mean Time (GMT). By setting your time zone using the /etc/localtime symlink, or the TZ environment variable, your system reports time to you and your apps based on your local timezone. If you have it set up right, you never need to change the time for DST as it is done automagically. My guess is that when the server was started, the TZ variable reflected your non-DST timezone (and each running app has its own copy of the environment variables), but since then your settings have been updated to correctly reflect DST automatically.

You should try poking around there for a bit. You might get away with simply restarting the web service.

service httpd restart

or

service apache restart

or whatever your system uses.
 
Old 04-14-2005, 03:32 AM   #9
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 75
Quote:
Originally posted by DJOtaku
don't have nntp -> get a command not found error when running as root. Any other suggestions?
Thats because its a service that you may have not installed. You need to install it and then enable it in services.
 
Old 04-14-2005, 09:06 AM   #10
oneandoneis2
Senior Member
 
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460

Rep: Reputation: 48
What about hwclock? Is this also reporting the correct time?
 
Old 04-14-2005, 10:13 AM   #11
DJOtaku
Member
 
Registered: Oct 2004
Location: USA
Distribution: Fedora 25;CentOS 7; Kubuntu; Debian
Posts: 860

Original Poster
Rep: Reputation: 36
Thank you for all of the great info, and I now know how to set the date and time. However, I think I know what may be the problem. Since date is returning the proper time, I don't think it's a system problem. I think it has to do with the fact that the services I use (phpBB and wordpress) use an offset from GMT to determine the time. Since GMT doesn't have daylight savings, I'll have to fix it manually within each program by just setting it to be GMT -4 instead of -5 or something like that. At least that's what came to me this morning. I will have to test and see if I'm right.
 
Old 04-15-2005, 11:41 AM   #12
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Listen to jmajor! You don't need to manually tweak it for every application every half year.

What TZ has your shell? What do the applications use? (Look in /proc/$pid/environ.)
Probably your shell's is good.
(To find out what you should use, run 'tzselect'. It won't change any settings, just print a suggestion.)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
change the time from the command line juanb Linux - Newbie 3 10-31-2007 02:11 AM
Network time through command line? Phaethar Linux - Software 2 05-06-2005 02:33 PM
Time commands from command line ToothlessRebel Linux - Newbie 1 03-09-2005 10:52 AM
setting system time via the command line ibm5_25 Linux - Software 3 01-18-2004 10:41 PM
altering the time at the command line vendemmian Linux - General 1 05-01-2001 06:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration