Skip to main content
3 of 5
added reason why OP does not get correct time stamp.
tlfong01
  • 4.8k
  • 3
  • 11
  • 24

Question

Run [bash/python] automatically at startup, timestamp is wrong, ...

Answer

Or you can try the python datetime thing.

python datetime

Update 2019jun05hkt2124

The OP says the following:

It works fine if I run the bash script manually through the command line, but if I allow it to run automatically at startup, the timestamps for files and archives are completely wrong. I'm not sure where to start with troubleshooting this issue.

I apologize that I suggested a solution but did not "troubleshoot" or explain why the OP gets the wrong time stamp.

The root cause is that linux does not update the user clock immediately after booting, and its reason is that it has too many higher priority (and less time consuming than getting network time) things to do (in the background) after booting. In other words, it is an engineering trade off and user experience/satisfaction vs system performance.

This is a quick and dirty update. Perhaps I can try a better explanation later.

tlfong01
  • 4.8k
  • 3
  • 11
  • 24