I have a python program that works through crontab and works fine. However, I decided to add the ability to notify me of what he was doing, and all of a sudden it fails. It starts from the command line, however, by running it as a crontab program, it causes a crash
libnotify-Message: Unable to get session bus: /bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.
What am I doing wrong?
Edit
I would like this program to still work from cron and be able to take advantage of a user notification about its operation. Is there any way to do this?
Edit 2
I tried using root crontab and sudo -u esr python script.py, but that also fails, silently at the same time.
Edit 3
Possibly! Here is the code.
* * * * * su $user -c "DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$(ps -au esr | grep -i "gnome-session" | awk '{ print $1 }')/environ | sed -e 's/DBUS_SESSION_BUS_ADDRESS=//') $(whereis notify-send | awk '{ print $2 }') -u normal -t 20000 \"Hello\" "
EricR