Operating System - HP-UX
1832855 Members
2746 Online
110047 Solutions
New Discussion

Re: how to set time backwards using scripts

 
SOLVED
Go to solution
Bala_8
Frequent Advisor

how to set time backwards using scripts

Hi,
I'm a DBA .... my application requirements are that every friday night i've to load the Development and Test databases with the PRODuction data ... all three databases reside in three different servers ... after loading the databases before restarting the database i need to set the system date to April 01, 2002 ... this is our business requirement to evaluate the application ....

I had automated the shutdown of databases, taking cold backup of PROD, ftp the files across the servers and recreate the development & test databases using create control file option using scripts ....

i created a cron entry to do this and activate it on every friday when my application team wants to have new set of data ...

My question is how to set the system date to april 01, 2002 thru scripts ....

i tried 'date 040104002002' as example ... but since i'm setting it backwards it asks for confirmation 'YES' from me .... how do i pass the 'yes' into my script which sets the date backwards ?????

thanks in advance
-bala-
5 REPLIES 5
Patrick Wallek
Honored Contributor
Solution

Re: how to set time backwards using scripts

You could try something like this:

date 040104002002 << EOF
YES
EOF

I don't know for sure that this will work, but it's worth a shot.
T G Manikandan
Honored Contributor

Re: how to set time backwards using scripts

Yes,what patrick suggested will work.

#script

date 040104002002 <yes
END

Thanks

Bala_8
Frequent Advisor

Re: how to set time backwards using scripts

Hi all,

Thanks for your fast response ....

i created a script with :

date 0401`date +%H%M` <yes
EOF

and it works... i use the inner date command to preserve the time ....

I've lot of jobs running using crontab, such as daily cold backup of database, clearing log files, pinning objects into oracle SGA, etc.

Will this change in date affect my crontab entries from running ???

cheers
-bala-
S.K. Chan
Honored Contributor

Re: how to set time backwards using scripts

Setting your system clock backwards can have side effects like you might have guessed (eg: crontab jobs). I would try to avoid doing so unless you have other processes in place to handle the cron entries after the clock changed. Active/open files may be written with the old timestamp, acive spooler jobs may get hung, among other things I can think of.
doug hosking
Esteemed Contributor

Re: how to set time backwards using scripts

Yes, please be careful if you set the time backward. Be especially careful with things like incremental backups! Other interesting things can happen with dependencies with 'make' and friends. Also, some versions of pwgrd are known to go into semi-infinite loops when time goes backwards. Beware if you are running that.