LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 07:58 AM   #1
fusion1275
Member
 
Registered: Jul 2007
Location: Knaphill, Surrey
Distribution: Linux Mint
Posts: 310

Rep: Reputation: 36
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, 08:36 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,481

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
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, 09:43 AM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,781

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
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, 09:46 AM   #4
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,481

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

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
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, 07:15 AM   #6
fusion1275
Member
 
Registered: Jul 2007
Location: Knaphill, Surrey
Distribution: Linux Mint
Posts: 310

Original Poster
Rep: Reputation: 36
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, 07:54 AM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,781

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
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, 08:54 AM   #8
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
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, 04:09 PM   #9
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,997

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
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, 06:44 PM   #10
DJ Shaji
Member
 
Registered: Dec 2004
Location: Yo Momma's house
Distribution: Fedora Rawhide, ArchLinux
Posts: 518
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



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 07:08 PM
[SOLVED] Insert a char and date into file in the same line everyday nelovicov Linux - Newbie 8 01-17-2012 11:28 AM
linux installation date in machine salimshahzad Linux - Newbie 5 10-23-2010 04:21 AM
real last modified date... not when copied to machine mike_stlouis Linux - Newbie 3 08-28-2009 01: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 09:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:04 PM.

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
Open Source Consulting | Domain Registration