Operating System - HP-UX
1834293 Members
2631 Online
110066 Solutions
New Discussion

Change date and time to 2 days ago.

 
SOLVED
Go to solution
Leo The Cat
Regular Advisor

Change date and time to 2 days ago.

Hi Guys

I'd like to change date and time for all files below /apps2 and subdir to (Example) June, the 30th 2008 00:00:00

How to do this, something like that with find and touch ?

Thanks in advance
Regards
Den
4 REPLIES 4
Steven E. Protter
Exalted Contributor

Re: Change date and time to 2 days ago.

Shalom Den,

This is done with the date command.

The command itself includes help and syntax.

If you do this with a running, open oracle database the database will crash and possibly be damaged.

You must bring critical services down before you do this.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor
Solution

Re: Change date and time to 2 days ago.

Hi Den:

Yes, use 'touch' to change a file's timestamp.

Now the question is, *whicH* timestamp? You can alter the lastaccess or the last modification ('-a' or '-m' respectively) but you cannot change the last "change" timestamp that you see with 'ls -c'.

# touch -at 06300000 myfile

...sets the lastaccess timestamp

# touch -mt 06300000

...sets the last modification timestamp

Add '-c' to the 'touch' command to prevent creating non-existent arguments.

See the manpages for 'touch' for more details!

For you question, you might do:

# find /apps2 -xdev -exec touch -amt 06300000 {} \+

Regards!

...JRF...
Regards!

...JRF...
Leo The Cat
Regular Advisor

Re: Change date and time to 2 days ago.

Hello

No, It's just for flat files.!
But the remark is pertinent for all players here !

Regards
Den
Leo The Cat
Regular Advisor

Re: Change date and time to 2 days ago.

James's solution do the job. Thanks!