Background: I successfully configured a DS3231 RTC to keep time and I can correctly read it with
hwclock -r or
hwclock -D commands.
Question: How do I store timestamp value (e.g. 1500075260) into a bash variable from
Note: Output from
hwclock -D command looks something like the next paragraph. I guess one way would be to store this output into a TXT file and get the timestamp by using text manipulation commands. I'd like to know if there is an easier way.
hwclock from util-linux 2.25.2 Using the /dev interface to the clock. Last drift adjustment done at 1500051827 seconds after 1969 Last calibration done at 1500051827 seconds after 1969 Hardware clock is on UTC time Assuming hardware clock is kept in UTC time. Waiting for clock tick... /dev/rtc does not have interrupt functions. Waiting in loop for time from /dev/rtc to change ...got clock tick Time read from Hardware Clock: 2017/07/14 23:34:20 Hw clock time : 2017/07/14 23:34:20 = 1500075260 seconds since 1969 Fri Jul 14 18:34:20 2017 -0.947188 seconds