I'm trying to record the start time of a process kicked off by an
@reboot cronjob. I'm using
ps -p $$ -o ltime= presently, but I've run into a catch.
My machine (a Raspberry Pi) connects to the network and pulls down an NTP update after cron has started and adjusts the system clock. The time returned by
lstart changes after the update (which does make sense, of course).
The problem is now I have two different start times, and it looks to my monitoring as if the process was restarted.
Since the reported start time changes when the NTP update comes down it seems like there's an underlying start-time notion that isn't affected by changes to the system clock (otherwise it would continue saying the process started at the old time). How can I get that underlying start-time from a process?
Excerpt from my system logs:
$ grep -e '@reboot' -e 'Time has been' -C 3 /var/log/syslog Apr 6 13:17:04 archer triggerhappy: Error opening '/dev/input/event*': No such file or directory Apr 6 13:17:04 archer kernel: [ 6.721869] usbcore: registered new interface driver brcmfmac Apr 6 13:17:04 archer kernel: [ 6.930684] brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: Dec 15 2015 18:10:45 version 18.104.22.168 (r606571) FWID 01-cc4eda9c Apr 6 13:17:04 archer cron: (CRON) INFO (Running @reboot jobs) Apr 6 13:17:04 archer wpa_supplicant: Successfully initialized wpa_supplicant Apr 6 13:17:04 archer dphys-swapfile: want /var/swap=100MByte, checking existing: keeping it Apr 6 13:17:04 archer avahi-daemon: Found user 'avahi' (UID 105) and group 'avahi' (GID 110). -- Apr 6 13:17:15 archer ntpd_intres: DNS 2.debian.pool.ntp.org -> 22.214.171.124 Apr 6 13:17:15 archer ntpd_intres: DNS 3.debian.pool.ntp.org -> 126.96.36.199 Apr 6 13:17:17 archer dhcpcd: wlan0: no IPv6 Routers available Apr 6 13:53:40 archer systemd: Time has been changed Apr 6 13:54:00 archer systemd: Starting user-1000.slice. Apr 6 13:54:00 archer systemd: Created slice user-1000.slice. Apr 6 13:54:00 archer systemd: Starting User Manager for UID 1000...
Notice the time-shift - before that point
lstart would report
13:17:04 but after it reports