i connect RTC to raspberry and when i execute thiese command time set correctly without internet connection :

echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
hwclock -s

but when i add these command to rc.local Rpi time wont set and date show Thu Jan 1 03:30:33 IRST 1970

and after boot i must manually enter only sudo hwclock -s to time set ...

why only hwclock -s wont execute in rc.local ?


I had the same issue, you need to add sudo before the hwclock -s command. Don't ask me why, since I have no idea. I was under the impression that rc.local is always run at highest privileges, but apparently that does not apply to hwclock. Infact most of the other commands I run in rc.local work without sudo. But not hwclock.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.