The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Get date and time for past 1 hour from current date spch2o Shell Programming and Scripting 5 08-29-2008 05:32 AM
Processing a log file based on date/time input and the date/time on the log file primp Shell Programming and Scripting 4 03-16-2008 11:23 AM
Move A File With Same Date,don't Change The Desitination Dir Date jee.ku2 UNIX for Dummies Questions & Answers 1 01-09-2008 01:42 PM
change time anhtt SUN Solaris 3 12-17-2007 11:13 AM
change the time in AIX rocker40 UNIX for Dummies Questions & Answers 1 03-15-2007 11:39 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 09-12-2008
samgdavies samgdavies is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 3
Temporarily change the date / time

Hi -

I'd like to know if it's possible to change the time on a Unix box temporarily, do some stuff, and then set it back to the correct time.

I'm testing some code that reads a time (in hours) from a config file, and does something at that time. I want to be able to run regression test scripts at any time.


I envisage doing something like this:
config file:
trigger.hour=7 // do something at 07:00

Invoke regression test script at any time, eg 14:57
- Test script uses date to set the time to 06:59:59
- The code gets invoked when the system time reaches 07:00:00
- Check the right thing happened (test = pass or fail)
- Set the time back to the correct current time (14:57 + ???)

The simplest thing would be if there's a command that goes and finds out what the time is that I can use to reset the clock after my test.
An alternative would be to save the current time, set it to the fake value, run the test, calculate how long the test lasted, and then set the time to (saved_time + elapsed_time) -- but I'm not sure how I would do all that in a shell script.

Any ideas welcome!
Thanks,
Sam
 

Bookmarks

Tags
change, date, temporary

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0