I recently upgraded from Ubuntu 12.04 to 14.04. I have a script which connects to a bookmarked chat and writes out a message. I am maintaining a cronjob to execute this after every half an hour. In 12.04 it worked fine.
*/30 11-19 * * 1-5 DISPLAY=:0;export DISPLAY;/path/script.py >> /path/errorStatus.log
The script correctly on executing through the terminal, but it is giving "Attach timeout" error on executing through the cron-job...
DISPLAY=:0;export DISPLAY;PID=$(pgrep gnome-session);dbus=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-);export DBUS_SESSION_BUS_ADDRESS=$dbus;/path/script.py >> /path/errorStatus.log
The cron job was not working as the env was not set correctly...
Firstly I tried running the script in cron environment :: -
How to simulate the environment cron executes a script with?
I compared the user-env and cron-env and found that exporting DBUS_SESSION_BUS_ADDRESS works for the script.