LinuxQuestions.org
Help answer threads with 0 replies.
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 03-17-2010, 09:14 AM   #1
kuravalasekhar
LQ Newbie
 
Registered: Jan 2010
Location: Bangalore
Posts: 3

Rep: Reputation: 0
Question how to add 5 years to current date


Dear All,

I am using Red hat Linux operating system.I want change the date exactly 5 years ago to current date with out providing month, date and time. I want only the year should be 5 years ago .please help in this regard
example

If current date is this = Wed mar 18 22:59:23 IST 2010

past date shuld be like this= Sat Mar 18 22:59:23 IST 2005
 
Old 03-17-2010, 09:27 AM   #2
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by kuravalasekhar View Post
Dear All,

I am using Red hat Linux operating system.I want change the date exactly 5 years ago to current date with out providing month, date and time. I want only the year should be 5 years ago .please help in this regard
example

If current date is this = Wed mar 18 22:59:23 IST 2010

past date shuld be like this= Sat Mar 18 22:59:23 IST 2005
use date --date=years ago

sorry if you only want certain parts use the


Code:
[root@xxx ~]# date --date='5 years ago'
Thu Mar 17 14:27:33 GMT 2005

errm...if you want only the year returned use

Code:
date --date "5 years ago" +%y

Last edited by centosboy; 03-17-2010 at 09:30 AM.
 
Old 03-18-2010, 01:17 AM   #3
kuravalasekhar
LQ Newbie
 
Registered: Jan 2010
Location: Bangalore
Posts: 3

Original Poster
Rep: Reputation: 0
Question

Quote:
Originally Posted by centosboy View Post
use date --date=years ago

sorry if you only want certain parts use the


Code:
[root@xxx ~]# date --date='5 years ago'
Thu Mar 17 14:27:33 GMT 2005

errm...if you want only the year returned use

Code:
date --date "5 years ago" +%y
Dear friend ,

i am not asking to just display .that date should be updated by 5 years ago and this should not updated by network.
 
Old 03-18-2010, 03:23 AM   #4
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by kuravalasekhar View Post
Dear friend ,

i am not asking to just display .that date should be updated by 5 years ago and this should not updated by network.
sorry - i dont understand....
 
Old 03-18-2010, 04:26 AM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,251

Rep: Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026
He wants to wind the clock back 5 years.
To avoid network update, see the ntp server:

service ntpd stop

Use chkconfig to turn it off permanently. You can also do it through the GUI if you've got it.

IMHO, the system will break if you do that; much software assumes time is ongoing ...

Why do you want to do this?
 
Old 03-18-2010, 10:28 AM   #6
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by kuravalasekhar View Post
Dear friend ,

i am not asking to just display .that date should be updated by 5 years ago and this should not updated by network.
Code:
date 031815252005
...

Code:
date MMDDhhmmCCYY
 
Old 03-18-2010, 10:36 AM   #7
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Debian, SL
Posts: 5,123

Rep: Reputation: 1104Reputation: 1104Reputation: 1104Reputation: 1104Reputation: 1104Reputation: 1104Reputation: 1104Reputation: 1104Reputation: 1104
Hint: you can do this by running the date command twice in the same commandline. Ie one invocation to print the date which is used as input to set the date. However I can imagine that doing this could cause all sorts of problems to running processes.

What may be a safer way is to reboot and reset the date in the bios, then when your system boots up it will read that date... I would still anticipate problems though, sicne you will have many files on your file systems that your os will think are dated up to 5 years in the future. You could play another trick by booting off a live cd, then mounting your drives and then use find and touch to change all the timestamps.

Hmm, this is all very dirty stuff.

Evo2.
 
  


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
Delete files based on current date -1 Winanjaya Linux - Newbie 3 06-23-2008 04:38 AM
find #of years from date monu Linux - General 4 10-15-2007 11:36 PM
slackware-current out-to-date? sparc86 Slackware 77 03-27-2007 08:42 AM
current date - yesterday's date newbie_adm Linux - Newbie 4 09-04-2006 03:56 PM
How do I add the current date to a filename? sammysrefuge Linux - Newbie 2 03-18-2005 02:43 PM


All times are GMT -5. The time now is 07:43 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration