You are not logged in.

#1 2013-03-02 18:17:24

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

[solved] Changing date but not time

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

#2 2013-03-02 18:27:05

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: [solved] Changing date but not time

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

#3 2013-03-02 19:19:13

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: [solved] Changing date but not time

Unfortunately not possible with the particular Adobe AIR program that I want to start.

Thus, I need a Bash solution which does not conflict with NTP's time setting.

Offline

#4 2013-03-02 19:36:08

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,033

Re: [solved] Changing date but not time

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

#5 2013-03-02 22:46:36

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: [solved] Changing date but not time

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

#6 2013-03-02 22:59:12

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [solved] Changing date but not time

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

#7 2013-03-02 23:10:32

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: [solved] Changing date but not time

*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

#8 2013-03-06 06:36:37

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: [solved] Changing date but not time

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

#9 2013-03-06 07:50:58

Awebb
Member
Registered: 2010-05-06
Posts: 6,688

Re: [solved] Changing date but not time

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

#10 2013-04-07 21:21:40

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: [solved] Changing date but not time

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

Board footer

Powered by FluxBB