EanderAlx.org

Linux, Virtualization and whatever I find interesting ...

User Tools


Site Tools


linux:notify_send_cron

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
blog:linux:notify-send-cron [30.09.2010 16:48] eanderalxblog:linux:notify_send_cron [17.01.2011 22:24] eanderalx
Line 1: Line 1:
 +====== 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.
 +
 +~~READMORE~~
 +<code>
 +libnotify-Message: Unable to get session bus: /usr/bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.
 +</code>
 +  * 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.:
 +<code>
 +echo `set | grep DBUS_SESSION_BUS_ADDRESS | cut -d "=" -f2-4` > /tmp/dbus_session_hostname
 +</code>
 +  * or (only with root privileges):
 +<code>
 +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
 +</code>
 +  * Now you can give this informations to notify-send and send the message to the correct user environment
 +  * e.g.:
 +<code>
 +sudo -u username DISPLAY=:0.0 DBUS_SESSION_BUS_ADDRESS=`cat /tmp/dbus_session_hostname` /usr/bin/notify-send Inventur "daily inventur complete"
 +</code>
 +  * 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.
linux/notify_send_cron.txt · Last modified: 23.03.2013 18:39 by eanderalx