I want a python script to send notification. The script can be run successfully and show what I want. but crontab did not boot it in right way.the following is the the code refer to the libnotify def SendMessage(title, message):    pynotify.init(ChinaBank)    notice = pynotify.Notification(title,message)    notice.show()    returnwhat I did in crontab is* * * * * display=`/home/li/script/FetchDisplay.sh` && export DISPLAY=$display && /home/li/projects/fetch-data/EuroForex.py 2>/home/li/errorHere, the FetchDisplay.sh is to get the display as following:#!/bin/bash if [ $DISPLAY !=  ]; then        echo $DISPLAY        exitfiif [$USER =  ]; then        USER=`whoami`fipinky -fw | awk -v user=$USER 'NF == 6 {if($1 == user) {print $6}}' | awk 'NR==1{print $0}the error output isTraceback (most recent call last):  File /home/li/projects/fetch-data/EuroForex.py, line 43, in <module>    SendMessage(Please be ready to sell, str(SellData))    File /home/li/projects/fetch-data/EuroForex.py, line 15, in SendMessage    notice.show()glib.GError: Error spawning command line 'dbus-launch --autolaunch=970be6bbf9ff49009918057c308cf56e --binary-syntax --close-stderr': Child process exited with code 1I know the DISPLAY is 0 through the command echo $DISPLAYtherefore, I test the gnome-screensaver-command with it.* * * * *  export DISPLAY=:0 && /usr/bin/gnome-screensaver-command --lock 2>/home/li/screenerrorUnfortunately, it did not work, and the output is** Message: Failed to get session bus: Error spawning command line 'dbus-launch --autolaunch=970be6bbf9ff49009918057c308cf56e --binary-syntax --close-stderr': Child process exited with code 1I thought it is the problem of DISPLAY, but the variable DISPLAY is correct. Could you tell what is going on?
dbus-laauch failed caused by the child process exited
cron;python;display;d bus;libnotify
I find the answer from here.Update Pidgin IM status on Ubuntu using croncron run in its own environment, therefore, we have to find the variables DBUS_SESSION_BUS_ADDRESS, XAUTHORITY, and DISPLAY.  I followed the instruction and succeeded to set the variables. My script can work now!