LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-13-2014, 08:58 AM   #1
fusion1275
Member
 
Registered: Jul 2007
Location: Portsmouth, Hants
Distribution: Linux Mint
Posts: 266

Rep: Reputation: 35
Linux machine on the same date everyday


Hi all,

I have a situation and want some advice please. So basically we a batch scheduling system at work and we are implementing a full migration from one clients system which is on HP-UX to RHEL. This involves migrating 2500 shell scripts, setting up the scheduler and importing all these scripts.

Anyway, these scripts rely on a financial data feed which we cant provide in our SIT environment and can only have a "cut" of data from the client to run against the scripts. Problem is, these scripts need the data to be within 3 days old or the code wont complete. (Its a criteria for this finance data). So I have been asked if I can set the test box up with the system date set constantly on a certain date. ie. It will never change from 20140513.

Is that actually possible?

Would love to hear your suggestions on this.

Cheers
 
Old 05-13-2014, 09:36 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,166

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
Sure, just schedule a cron job to run at 1 minute past midnight each day to run date -s and reset the date to whatever you want.

Just set the date not the whole date/time.
 
Old 05-13-2014, 10:43 AM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2,959

Rep: Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268
Unix-like systems have a history of sometimes reacting badly to large negative time shifts (timeouts that should be a few seconds don't trigger for a long time, etc.), so you might need to reboot with the BIOS date set to that certain date (and of course with NTP or other time synchronization tools disabled). Sometimes it works OK, just don't be too surprised if some parts of the system misbehave after you've set back the date on a running system.
 
Old 05-13-2014, 10:46 AM   #4
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,166

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
I suppose a scripted reboot of the server could also be done as part of the date fudge.
 
Old 05-13-2014, 10:30 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 15,374

Rep: Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198
Setting time on boot with a script may work. Not sure how this would affect your data however. Even changing date one time may cause some unexpected results.

At one time I explored a way to stop time (rtc) in order to get past some of these issues. It was a long time ago and may not be possible anymore.
 
Old 05-14-2014, 08:15 AM   #6
fusion1275
Member
 
Registered: Jul 2007
Location: Portsmouth, Hants
Distribution: Linux Mint
Posts: 266

Original Poster
Rep: Reputation: 35
Thanks so much for all your input.

Another questions is...

Would "hwclock" need to be looked at to? Would that need to be re-set along with using the "date" command?

Cheers
 
Old 05-14-2014, 08:54 AM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2,959

Rep: Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268
The hardware clock is only consulted during boot. You can certainly run "hwclock --systohc" after setting the date. Many (most?) distros do that during shutdown, so if you do find that a reboot is needed, setting the date and then rebooting should take care of it.

However you do it, you will of course be left with various files/filesystems with timestamps in the future. Working around or resetting those is left as an exercise for the student sysadmin.
 
Old 05-14-2014, 09:54 AM   #8
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 805

Rep: Reputation: 186Reputation: 186
An alternate way is to increment the dates in test data suite everyday. Needs good documentation and housekeeping procedures.

Possible?
Less bothersome?

OK
 
Old 05-14-2014, 05:09 PM   #9
jefro
Moderator
 
Registered: Mar 2008
Posts: 15,374

Rep: Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198
At one time one could change speed so that an hour was a week or such. It worked OK, not sure how to do that anymore.
 
Old 05-14-2014, 07:44 PM   #10
DJ Shaji
Member
 
Registered: Dec 2004
Distribution: Fedora 22 (Twenty Two!), ArchLinux
Posts: 506
Blog Entries: 15

Rep: Reputation: 106Reputation: 106
Resetting the time can have serious consequences. What kind of scripts are these? How are they getting the date? Couldn't you modify the function(s) that provide the date to return a static date every time it's called? System wide date reset is probably best done through a cron job, and I feel it's a bad idea. I wouldn't do it.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hello from an Everyday Linux User everydaylinuxuser LinuxQuestions.org Member Intro 2 04-04-2014 08:08 PM
[SOLVED] Insert a char and date into file in the same line everyday nelovicov Linux - Newbie 8 01-17-2012 12:28 PM
linux installation date in machine salimshahzad Linux - Newbie 5 10-23-2010 05:21 AM
real last modified date... not when copied to machine mike_stlouis Linux - Newbie 3 08-28-2009 02:17 PM
how to find the time and date when linux was installed on my machine? Fond_of_Opensource Linux - Newbie 2 07-02-2008 10:07 AM


All times are GMT -5. The time now is 10:37 AM.

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