Xfce Forum

Sub domains
 

You are not logged in.

#1 2023-05-04 08:13:02

UT_qx13s
Member
Registered: 2023-05-04
Posts: 7

[SOLVED] Log-out From Cron Stopped Working

Up until about a month ago I was able to successfully run the following command from cron:

pgrep -l xlock && $xfce4_session_logout --suspend

Now I get the following pop-up message each time it runs:

Received error while trying to log out, error was GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.xfce.SessionManager was not provided by any .service files

My xfce4-session version is 4.18.2.

Any idea what I need to change to get it working again?

It works when I test-run it from the command line, fwiw.

Last edited by UT_qx13s (2023-05-07 00:42:33)

Offline

#2 2023-05-04 10:47:18

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,801

Re: [SOLVED] Log-out From Cron Stopped Working

Hello and welcome.

What does the variable $xfce4_session_logout contain?

Generally, cron doesn't know about your user session, and in this instance, it needs the dbus session bus address of your user session to run this command.

$ env | grep DBUS
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus

Cron entry:

* * * * * DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus xfce4-session-logout --logout

Not sure how it worked before though, too many unknowns (distro, updates, etc)


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2023-05-04 22:33:25

UT_qx13s
Member
Registered: 2023-05-04
Posts: 7

Re: [SOLVED] Log-out From Cron Stopped Working

Hi ToZ,

ToZ wrote:

What does the variable $xfce4_session_logout contain?

It's just a shell variable holding the absolute path to the executable.

ToZ wrote:

Generally, cron doesn't know about your user session, and in this instance, it needs the dbus session bus address of your user session to run this command.

Makes sense. When I first wrote it, the job failed because DISPLAY wasn't defined.

My address appears set to a tmp file. Clearing tmp didn't fix it during my troubleshooting, which prompted me to post here for help. That's a hell of a GUID. Is that normal?

$ env | grep DBUS
DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/dbus-9ZyT0kppt5,guid=12bef731053d2ed3151c71006451aae5

Will try setting the address in cron. Thanks.

ToZ wrote:

Not sure how it worked before though, too many unknowns (distro, updates, etc)

After some searching, it looks like it coincided with an xfce4-session upgrade from 4.18.0 to 4.18.2. The first error message it spat out was that my machine-id was corrupted (it was set to a series of j). Fixing that got me to the current error message.

Offline

#4 2023-05-05 01:17:51

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,801

Re: [SOLVED] Log-out From Cron Stopped Working

Which distro are you using and is it systemd based? And how are you starting it (display manager or startx)?

dbus address on systemd changed a while back to use /run/user, but you need to run dbus-update-activation-environment during login.

Fixing that got me to the current error message.

Did you try changing your cron to reference this dbus session bus address?


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#5 2023-05-05 02:43:56

UT_qx13s
Member
Registered: 2023-05-04
Posts: 7

Re: [SOLVED] Log-out From Cron Stopped Working

ToZ wrote:

Which distro are you using and is it systemd based?

The Great and Wonderful FreeBSD. Not systemd based.

ToZ wrote:

And how are you starting it (display manager or startx)?

I think it's started with this script:

$ cat .xsession
export LIBGL_DRI3_DISABLE=1
source /usr/local/etc/xdg/xfce4/xinitrc
ToZ wrote:

dbus address on systemd changed a while back to use /run/user, but you need to run dbus-update-activation-environment during login.

The OS isn't systemd-based, but there also hasn't been a FreeBSD system update in awhile. The breakage did coincide with a large packages update on April 8th. That's the first time the job failed to suspend the system, and I found a stack of pop-ups with error messages.

ToZ wrote:

Did you try changing your cron to reference this dbus session bus address?

Will try that tonight and let you know how it goes. Thanks again.

Offline

#6 2023-05-06 00:31:46

UT_qx13s
Member
Registered: 2023-05-04
Posts: 7

Re: [SOLVED] Log-out From Cron Stopped Working

ToZ wrote:

Did you try changing your cron to reference this dbus session bus address?

Okay, this worked. However, whenever I reboot the system, that address will change again. I currently have the cron job configure like so:

$ crontab -l | awk '/sus|sess/'
xfce4_session_logout=/home/UT_qx13s/.bin/xfce4-session-logout.cron
# suspend system after periodic scripts run iff session is locked
*/5 6 1    * *      -n pgrep -q xlock && $xfce4_session_logout
*/5 5 2-31 * 6      -n pgrep -q xlock && $xfce4_session_logout
*/5 4 2-31 * 1-5,7  -n pgrep -q xlock && $xfce4_session_logout

And,

$ !cat
cat .bin/xfce4-session-logout.cron 
#!/bin/sh

export DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/dbus-nwBNA8LmLz
export DISPLAY=:0.0
/usr/local/bin/xfce4-session-logout --suspend

Is there no automatic way to set that address anymore? Somehow it was being exported to the crontab prior to the package update, but now apparently doesn't.

Offline

#7 2023-05-06 14:02:10

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,801

Re: [SOLVED] Log-out From Cron Stopped Working

However, whenever I reboot the system, that address will change again.

How about using procstat to pull out the current value. Something like:

procstat -e $(pgrep xfce4-session) | sed 's/ /\n/g' | grep DBUS

Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#8 2023-05-06 22:21:28

UT_qx13s
Member
Registered: 2023-05-04
Posts: 7

Re: [SOLVED] Log-out From Cron Stopped Working

ToZ wrote:

How about using procstat to pull out the current value.

That works. Thank you for your help.

$ procstat -e $(pgrep xfce4-session) | sed -nr 's/.*(DBUS[^,]*).*/\1/p'
DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/dbus-nwBNA8LmLz

Last edited by UT_qx13s (2023-05-07 00:41:23)

Offline

Registered users online in this topic: 0, guests: 1
[Bot] CCBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.015 seconds, 12 queries executed - Memory usage: 554.81 KiB (Peak: 571.66 KiB) ]