You are not logged in.
Pages: 1
Hello,
I already searched the web but all examples how to change date involved changing time as well.
date -s "7 April 2008 20:42:45"
date -s "7 April 2008 20:42:45"I need a script that does the follow.
1. Save the current date
2. Change the date to a defined one (but not the time because that conflicts with NTP)
3. Start a program
4. Wait for the program to be closed to restore the original date saved in 1.
How would you write such a script in Bash without changing the time?
Last edited by orschiro (2013-04-07 21:22:52)
Offline
If you all want to do is fake the date for a specific process you may want to use the faketime command from the libfaketime package instead.
Offline
What's wrong with the program? Why would it need the date changed?
Have you tried
date -s '7 April 2008'
?
You're just jealous because the voices only talk to me.
Offline
ntp maintains the date as well as the time, so far as I know. So anything which fiddles with the date will interfere with ntp.
Doing this is a terrible idea as it will screw up all kinds of other things on the system. When programmes look at times of files etc, they are looking at date/time and not just time of day.
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
The way a computer calculates date/time is by the number of seconds from Jan 1, 1969. So changing the date IS changing the time.
Offline
*scratches head*
I'm also curious what this would be for. I don't want to jump to a conclusion, but the only reason I can see for doing this would be to try to circumvent a limited trial-period license. If this is the case you should not be doing it, and you should definitely not be asking about it here.
I hope I'm wrong, so if I am, could you put my (our) mind(s) at ease and describe the end goal?
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thanks for your replies. I did not know that time and date are inevitably connected to each other and that changing date does always mean changing time as well.
@Trilby,
I indeed want to circumvent a trial-period. I am working on a Linux compatibility version of Prezi Desktop which is no longer provided in an official version. Many people contacted me with issues they are facing that I cannot testify as I do not have a 'Pro' account for which one has to pay. I generally pay for software but in this special case I do not want to pay for an account realising that in fact I cannot use the software due to compatibility issues.
As such, I already tried libfaketime but I failed to get it working with Adobe AIR 32bit on my 64bit system. I am aware that I am doing something that I ought not to do but I am not willed to pay for broken software.
@moetunes
[orschiro@thinkpad ~]$ date -s '7 April 2008'
date: cannot set date: Operation not permitted
Mo 7. Apr 00:00:00 CEST 2008
You see, date -s would reset the time to 00:00 which is not what I was looking for. I want to save my current time to restore it again after closing the program.
Offline
Create a script that…
on {
- reads the time and date
- stops ntp
- writes the time + the new date
}
off {
- reads the time
-writes the time + correct date from earlier
-starts ntp
}
Offline
The developer of libfaketime found a bug which caused libfaketime to stop working with adobe-adl programs such as Prezi.
However, there is a compiled library with an implemented workaround.
Offline
Pages: 1