Ubuntu – Cannot run a GUI app from cron

cronxorg

After doing a "sudo su -" on an Ubuntu 12.04 notebook I did a "crontab -e", added this:

* * * * * env DISPLAY=:0.0 /usr/bin/gnome-calculator

and waited for minutes. Nothing Happened. I don't have any external monitors and if I run this command "env DISPLAY=:0.0 /usr/bin/gnome-calculator" in the terminal, it just works. But not from cron. Why?

The syslog only contains this:

May 24 14:37:01 localhost cron[1227]: (root) RELOAD (crontabs/root)
May 24 14:37:01 localhost CRON[16432]: (root) CMD (env DISPLAY=:0.0 /usr/bin/gnome-calculator )

And I already tried an "xhost +localhost".

[root@NOTEBOOK /var/log] xhost
access control enabled, only authorized clients can connect
INET:localhost.localdomain
SI:localuser:USERNAME
[root@NOTEBOOK /var/log] 

So the solution for another question like this on askubunut didn't worked.

Best Answer

Rewritten as an answer per OP's request.

It's probably not a good idea to put this in the root crontab un the first place. Have you tried putting it un your user crontab?

Related Question