Skip to main content
mention the timedatectl command
Source Link
ckujau
  • 1.5k
  • 8
  • 17

One could setup a sudo rule to allow the execution of hwclock without any arguments:

%sudo ALL=(ALL) NOPASSWD: /sbin/hwclock ""

Or grant read access to the RTC character device:

 $ groups johnny sudo staff $ sudo setfacl -m g:sudo:r /dev/rtc $ /sbin/hwclock Sun 18 Dec 2016 03:16:37 PM PST -0.318689 seconds 

This may have to be set after every reboot, as /dev is most likely volatile these days. I suppose an udev rule could handle this too.

In newer systemd-based systems, the timedatectl command is able to get the hardware clock w/o special permissions:

 $ timedatectl | head -3 Local time: Sun 2016-12-18 15:43:08 PST Universal time: Sun 2016-12-18 23:43:08 UTC RTC time: Sun 2016-12-18 23:43:08 

One could setup a sudo rule to allow the execution of hwclock without any arguments:

%sudo ALL=(ALL) NOPASSWD: /sbin/hwclock ""

Or grant read access to the RTC character device:

 $ groups johnny sudo staff $ sudo setfacl -m g:sudo:r /dev/rtc $ /sbin/hwclock Sun 18 Dec 2016 03:16:37 PM PST -0.318689 seconds 

This may have to be set after every reboot, as /dev is most likely volatile these days. I suppose an udev rule could handle this too.

One could setup a sudo rule to allow the execution of hwclock without any arguments:

%sudo ALL=(ALL) NOPASSWD: /sbin/hwclock ""

Or grant read access to the RTC character device:

 $ groups johnny sudo staff $ sudo setfacl -m g:sudo:r /dev/rtc $ /sbin/hwclock Sun 18 Dec 2016 03:16:37 PM PST -0.318689 seconds 

This may have to be set after every reboot, as /dev is most likely volatile these days. I suppose an udev rule could handle this too.

In newer systemd-based systems, the timedatectl command is able to get the hardware clock w/o special permissions:

 $ timedatectl | head -3 Local time: Sun 2016-12-18 15:43:08 PST Universal time: Sun 2016-12-18 23:43:08 UTC RTC time: Sun 2016-12-18 23:43:08 
Source Link
ckujau
  • 1.5k
  • 8
  • 17

One could setup a sudo rule to allow the execution of hwclock without any arguments:

%sudo ALL=(ALL) NOPASSWD: /sbin/hwclock ""

Or grant read access to the RTC character device:

 $ groups johnny sudo staff $ sudo setfacl -m g:sudo:r /dev/rtc $ /sbin/hwclock Sun 18 Dec 2016 03:16:37 PM PST -0.318689 seconds 

This may have to be set after every reboot, as /dev is most likely volatile these days. I suppose an udev rule could handle this too.