You are not logged in.
I use https://wiki.archlinux.org/index.php/Systemd/User which works fine; but I also have a cronjob which should restart a certain (user) service. This doesn't work; the cronjob says:
Failed to get D-Bus connection: Connection refused
I have the same issue when su-ing to the user, which is why I have a suspicion this is related to https://bugzilla.redhat.com/show_bug.cgi?id=753882.
Does anyone here have this working; or possible solution?
Okay I found a workaround:
[[ -z $XDG_RUNTIME_DIR ]] && export XDG_RUNTIME_DIR=/run/user/$UID
Last edited by Spider.007 (2014-09-05 08:51:26)
Offline
I am having the same problem, but it affects all user services, even running "systemctl --user status" fails because it can not connect to D-Bus. Your workaround went in you're shells configuration file I assume (bashrc, zshrc, etc)?
Offline
Okay I found a workaround:
[[ -z $XDG_RUNTIME_DIR ]] && export XDG_RUNTIME_DIR=/run/user/$UID
Thanks a lot
In my case, I did this :
First, I edit the sudo's configuration file, with the visudo command.
And finally :
# This is the UID of the user "pikachu" :
PIKACHU_UID=1008
sudo -u pikachu -H XDG_RUNTIME_DIR=/run/user/$PIKACHU_UID systemctl --user start something.service
Sorry ! My English is not perfect
Offline
but I also have a cronjob which should restart a certain (user) service
You could use a timer instead: https://wiki.archlinux.org/index.php/Systemd/Timers
[Unit]
Description=Do something daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timer.target
[Unit]
Description=Restart service
[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl try-restart my_program.service
Every time I see some piece of medical research saying that caffeine is good for you, I high-five myself. Because I'm going to live forever. -- Torvalds, Linus (2010-08-03).
Offline
Setting XDG_RUNTIME_DIR and using sudo is hackish... Have you tried using either systemd user instance's timers or per-user cron tables?
Offline
but I also have a cronjob which should restart a certain (user) service
You could use a timer instead: https://wiki.archlinux.org/index.php/Systemd/Timers
[...]
Thanks; that's a good suggestion. Unfortunately for me it doesn't work; the restart is part of a bigger script that should be performed after certain updates are completed
Setting XDG_RUNTIME_DIR and using sudo is hackish... Have you tried using either systemd user instance's timers or per-user cron tables?
The whole point is systemd-user instances can only be controlled by logged in users. Not by cron-jobs that run under that users credentials....
Offline
Have you tried using either systemd user instance's timers or per-user cron tables?
Spider.007 needs timers or cronjobs, not me
Setting XDG_RUNTIME_DIR and using sudo is hackish.
My problem is : how does user_B to stop, reload, mask, enable … an unit which is launched by the user_A's systemd instance ?
For example : the wiki talks about a user version of the mpd service, which is launched by the systemd instance of the user "mpd". How does the user "intelfx" to stop, reload, mask, enable … this unit ?
Using sudo and XDG_RUNTIME_DIR seems to work. Does an other solution exist ?
Sorry ! My English is not perfect
Offline
intelfx wrote:Have you tried using either systemd user instance's timers or per-user cron tables?
Spider.007 needs timers or cronjobs, not me
intelfx wrote:Setting XDG_RUNTIME_DIR and using sudo is hackish.
My problem is : how does user_B to stop, reload, mask, enable … an unit which is launched by the user_A's systemd instance ?
For example : the wiki talks about a user version of the mpd service, which is launched by the systemd instance of the user "mpd". How does the user "intelfx" to stop, reload, mask, enable … this unit ?
Using sudo and XDG_RUNTIME_DIR seems to work. Does an other solution exist ?
Please start your own thread. Forum Etiquette: Thread Hijacking. Thanks.
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline