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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-13-2005, 07:21 PM
|
#1
|
Member
Registered: Oct 2004
Location: USA
Distribution: Fedora 25;CentOS 7; Kubuntu; Debian
Posts: 860
Rep:
|
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,
|
|
|
04-13-2005, 07:23 PM
|
#2
|
Senior Member
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524
Rep:
|
man date
|
|
|
04-13-2005, 07:34 PM
|
#3
|
Senior Member
Registered: Oct 2003
Posts: 3,057
Rep:
|
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"
|
|
|
04-13-2005, 07:47 PM
|
#4
|
Member
Registered: Sep 2002
Posts: 310
Rep:
|
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
|
|
|
04-13-2005, 11:52 PM
|
#5
|
Member
Registered: Oct 2004
Location: USA
Distribution: Fedora 25;CentOS 7; Kubuntu; Debian
Posts: 860
Original Poster
Rep:
|
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
|
|
|
04-14-2005, 12:38 AM
|
#6
|
LQ Guru
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298
Rep:
|
You could run nntp and this updates the clock automatically, because your system syncs its time with another server on the internet.
|
|
|
04-14-2005, 01:16 AM
|
#7
|
Member
Registered: Oct 2004
Location: USA
Distribution: Fedora 25;CentOS 7; Kubuntu; Debian
Posts: 860
Original Poster
Rep:
|
don't have nntp -> get a command not found error when running as root. Any other suggestions?
|
|
|
04-14-2005, 02:34 AM
|
#8
|
Member
Registered: Nov 2004
Location: Australia
Distribution: Fedora, Ubuntu
Posts: 55
Rep:
|
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.
|
|
|
04-14-2005, 04:32 AM
|
#9
|
LQ Guru
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298
Rep:
|
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.
|
|
|
04-14-2005, 10:06 AM
|
#10
|
Senior Member
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460
Rep:
|
What about hwclock? Is this also reporting the correct time?
|
|
|
04-14-2005, 11:13 AM
|
#11
|
Member
Registered: Oct 2004
Location: USA
Distribution: Fedora 25;CentOS 7; Kubuntu; Debian
Posts: 860
Original Poster
Rep:
|
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.
|
|
|
04-15-2005, 12:41 PM
|
#12
|
Member
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377
Rep:
|
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.)
|
|
|
All times are GMT -5. The time now is 10:30 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|