Dav*_*ish 5 linux sudo systemd
我有一些用户在 Ubuntu 和 Arch Linux systemd 系统上以 linger 模式运行。这意味着,即使用户没有登录系统,他们的计时器也可以运行。作为 root 用户,我如何才能看到所有活动的计时器,包括所有用户的计时器?
systemctl list-timers
会给我系统计时器。如果我以用户身份登录,systemctl --user list-timers
则会向我提供该用户的计时器。但是,如果我跑步sudo -u anotheruser systemctl --user list-timers
,那么我会得到Failed to connect to bus: No such file or directory
。
感谢 Freenode #systemd IRC 频道(用户 dreisner 和 damjan),我了解到 systemd 需要用户运行systemctl --user list-timers
才能打印正在运行的计时器。
如果系统管理员想要sudo
或su
作为其他用户查看计时器,那么他们需要设置XDG_RUNTIME_DIR
环境变量。
例如sudo -u $anotheruser XDG_RUNTIME_DIR=/run/user/$anotheruser_uid systemctl --user list-timers
将返回$anotheruser
计时器。
为了自动执行查看系统上所有计时器的过程,我在Bash和Haskell中创建了一个脚本。
归档时间: |
|
查看次数: |
3312 次 |
最近记录: |