linux - Generate time serie in iso-8601 format using date command, how to deal with server system date origin offset? -


I have the following bash function that generates an age list in the Iso-8601 format on a machine that runs Ubuntu and It works fine. (Where to test input and IITTS bash work input)

  gen_epoch () {# USAGE: gen_epoch [start_date_iso] [end_date_iso] [increment_in_seconds] # @ # @ task: an era list Generate (era list in isodet format). # @ STDOUT Results: [Europe_list] # @ ErrorGode: 2 0 # # Test Arguments if ["$ #" -3]; Then repeat "$ FUNCNAME: Input Error [NB_Of_Input]"; Return 2 alif [$ (island $ 1 & amp;; / dev / null; resonance $?) -ece 2]; Then resize "$ FUNCNAME: Logic Error [$ 1]"; Return 2 Alief [$ (Island $ 2 & amp;; / dev / null; echo $?) -Ece 2]; Then resize "$ FUNCNAME: Logic Error [$ 2]"; Return 2 Alief [$ (IITT $ 3 & amp;; / dev / null; echo $?) -Ece 2]; Then repeat "$ FUNCNAME: Logic error [$ 3]"; Return 2 and local beg = $ (TZ = UTC date --date = "$ 1" +% s); Local end = $ (tees = utc date --date = "$ 2" +% s); Local Inc = $ 3; Fi ## [$ begole $ end] local date_out = $ (TZ = UTC date --date = "UTC $ 1970-01-01 $ secs" --iso-8601 = sec) when generating the era; This command line generates the expected value for example: $ {date> 01T00: 00: 00 2014-04-0107: 00: 00 3600   

Expected value:

  2014-04-01T00: 00: 00 2014- 04-01T01: 00: 00 2014-04-01T02: 00: 00 2014-04-010 03: 00: 00 2014-04-0104: 00: 00 2014-04-01005: 00: 00 2014-04-01006: 00: 00 2014-04-0107: 00: 00   

Although I have tried this function on the server where I do not have any root privileges and I have found the following results : Code: 2014-03-31 T17: 00: 00 2014-03-31 T 18: 00: 00 2014-03-31 T 19: 00: 00 2014-03-31 T20: 00: 00 2014-03-31 T21: 00: 00 2014-03-31 T22: 00: 00 2014-03-31 T23: 00: 00 2014 -04-01000: 00: 00

And I have noticed that the time of the server is original 01-01-01-01 not 00: 00: 00 typing TZ = UTC date Returns the value of --date = "1970-01-01T00: 00: 00" +% s command -25200 which corresponds to 7 hours while it should be 0 interval. My question is how can this problem be corrected on the server? Can you help me find a solution similar to this function, assuming that I do not know about which machine I'm running it, so I know that the timing of the system is correct or not?

is not a complete answer, but is too long for a comment.

I think it is configured incorrectly on this particular server setup. The problem is that BIOS clocks are set at local time, whereas the system thinks that it is in UTC (or vise versa) (use hwclock to query hardware code settings) .

If the system is configured incorrectly and you can not fix it for any reason (superuser account or whatever), I provide a fixing timezone description file with my software I recommend and specify it in the TZ variable like this: code> TZ =: / path / to / fixing / timezone date --date = "1970-01-01T00: 00: 00" +% s Clearly you have to pre-calculate which TZ details file fixes Issue and use of an appropriate one. Usually available timezone / usr / share / zoneinfo are stored in the

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -