EanderAlx.org

Linux, Virtualization and whatever I find interesting ...

User Tools


Site Tools


linux:notify_send_cron

notify-send from cron

tested with Arch x64 and Gnome 2.3

  • If you send an notfiy-send from a cron and use gnome then you normally get an error message.

libnotify-Message: Unable to get session bus: /usr/bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.
  • The right User Environment is missing in crontab.

Solution

  • You have to save your dbus-session ID and have to know the screen to which the message is send.
  • e.g.:
echo `set | grep DBUS_SESSION_BUS_ADDRESS | cut -d "=" -f2-4` > /tmp/dbus_session_hostname
  • or (only with root privileges):
sudo grep -z DBUS_SESSION_BUS_ADDRESS /proc/`/bin/pidof gnome-session`/environ | cut  -d "=" -f2-4 > /tmp/dbus_session_id
CONTENT=`cat /tmp/dbus_session_id`
echo $CONTENT > /tmp/dbus_session_id
  • Now you can give this informations to notify-send and send the message to the correct user environment
  • e.g.:
sudo -u username DISPLAY=:0.0 DBUS_SESSION_BUS_ADDRESS=`cat /tmp/dbus_session_hostname` /usr/bin/notify-send Inventur "daily inventur complete"
  • With “sudo -u” you can send the message from root crontab to a special user else it will send to the owner of the crontab.
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
linux/notify_send_cron.1295299458.txt.gz · Last modified: 17.01.2011 22:24 by eanderalx