Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I Need to change the date 1

Status
Not open for further replies.

rankar

IS-IT--Management
Jul 30, 2001
60
US
I would like to change the date using the date command,I tried using [date -s set=Tue Jun 25 15:00:00 MST 2002] but it doesn't work, any suggestions would be very helpful.

Thanks,
Rankar
 
You have to use the date command in this format...

date MMDDhhmmYY.ss

MM = Month
DD = Day
hh = hour
mm = minute
YY = year
.ss = seconds

The year and seconds are optional.

To change the date to 6/25/02, 6:40pm...

[root@penguin root]# date 0625184002.00
Tue Jun 25 18:40:00 EDT 2002


ChrisP ---------------------------------------
If someone's post was helpful to you, please click the box "Click here to mark this post as a helpful or expert post".
 
Thanks Chrisp, what about the time zone can I use the same format to list the timezone?

Rankar
 
This is different. In Red Hat, your timezone is determined by the /etc/localtime file. This file should by linked to a file in /usr/share/zoneinfo/. The /usr/share/zoneinfo/ directory contains files for each time zone.

# First back up the /etc/localtime file
[root@penguin /]# mv /etc/localtime /etc/localtime.old

# Delete the /etc/localtime file
[root@penguin /]# rm -f /etc/localtime

# Lets change the timezone to Cuba's time
[root@penguin /]# ln -s /usr/share/zoneinfo/Cuba /etc/localtime
[root@penguin /]# date
Wed Jun 26 08:33:35 CDT 2002

# Lets change it back to US Eastern time (where I live)
[root@penguin /]# rm -f /etc/localtime
[root@penguin /]# ln -s /usr/share/zoneinfo/US/Eastern /etc/localtime
[root@penguin /]# date
Wed Jun 26 08:34:40 EDT 2002


ChrisP ---------------------------------------
If someone's post was helpful to you, please click the box "Click here to mark this post as a helpful or expert post".
 
Oh, I just found a really easy solution to changing the timezone. From a command prompt, type 'timeconfig'. This gives you a simple menu for changing the time zone. This is on Red Hat, I'm not sure about other distro's.

ChrisP ---------------------------------------
If someone's post was helpful to you, please click the box "Click here to mark this post as a helpful or expert post".
 
Thanks again ChrisP, it worked like a charm.
 
how will i change the setting of time and date in my linux server coz when i type the date command i see the curent date but when i see the output on my scrip the date is not update. pls. help me

thanks
 
Which Linux distro and version? I think in earlier distro's you had to set the hardware clock too. I think you can do it with this command...

hwclock --systohc


ChrisP ------------------------------------------------------------------------------
If somebody helps you, please click the link in the botton left hand corner that says "Mark this post as a helpful/expert post".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top