Settimeofday cant change the time in L4T on a TX2

Hi All,

I tried to do settimeofday in a C program running in Linux for Tegra on a TX2, but when I do gettimeofday right away in my program, the time is unchanged from when I did gettimeofday before doing settimeofday. I am using printf()s to output tv.tv_sec, where tv is the timeval type. I found this post: ubuntu - settimeofday function can't change time - Unix & Linux Stack Exchange and found that I have systemd-timesyncd.service running. I stopped it by doing “sudo systemctl stop systemd-timesyncd.service” and verified that it was inactive. I still couldn’t change the time.

I did:
$ ps -ef | grep time and got (UID redacted):
7576 6683 0 17:40 ? 00:00:01 /usr/lib/aarch64-linux-gnu/indicator-datetime/indicator-datetime-service
9755 9733 0 19:51 pts/0 00:00:00 systemctl status systemd-timesyncd
9922 9733 0 21:09 pts/0 00:00:00 systemctl status systemd-timesyncd
10001 9733 0 21:51 pts/0 00:00:00 systemctl status systemd-timesyncd
10092 9733 0 22:19 pts/0 00:00:00 systemctl status systemd-timesyncd
10132 9733 0 22:45 pts/0 00:00:00 grep --color=auto time
The column order above is:
PID PPID C STIME TTY TIME CMD

I killed all of those process and then still got:
$ ps -ef | grep time
9755 9733 0 19:51 pts/0 00:00:00 systemctl status systemd-timesyncd
9922 9733 0 21:09 pts/0 00:00:00 systemctl status systemd-timesyncd
10001 9733 0 21:51 pts/0 00:00:00 systemctl status systemd-timesyncd
10092 9733 0 22:19 pts/0 00:00:00 systemctl status systemd-timesyncd
10163 9733 0 22:59 pts/0 00:00:00 grep --color=auto time

I still couldn’t change the time. Does anyone have any ideas? Thanks in advance for your help.

Edit: It reads back unchanged so quickly in the next line of code it’s as if the time was not writable.

Best regards,

It was found that settimeofday was failing and the errno was 1, EPERM, “Operation not permitted”. Running the executable with sudo allowed settimeofday to change the time.