How can I view systemd timers for all users?

3

I have some users running in linger mode on Ubuntu and Arch Linux systemd systems. Meaning, users' timers can be running even if they are not logged into the system. As a root user, how can I see all the timers active, including all of the users' timers?

systemctl list-timers will give me the system timers. If I am logged in as a user systemctl --user list-timers will give me the timers for that user. However, if I run sudo -u anotheruser systemctl --user list-timers then I get Failed to connect to bus: No such file or directory.

Dave Parrish

Posted 2016-10-03T03:14:52.283

Reputation: 561

Answers

2

Thanks to the Freenode #systemd IRC channel (users dreisner and damjan), I learned that systemd requires the user to run systemctl --user list-timers in order to print the running timers.

If an administrator of the system wants to sudo or su as another user in order to see the timers, then they need to set XDG_RUNTIME_DIR envrionment variable.

For example sudo -u $anotheruser XDG_RUNTIME_DIR=/run/user/$anotheruser_uid systemctl --user list-timers will return $anotheruser timers.

To automate the process of viewing all timers on the system, I created a script in Bash and Haskell.

Dave Parrish

Posted 2016-10-03T03:14:52.283

Reputation: 561