Cannot run a GUI app from cron

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?


I think this is the issue:

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

Setting to it to this seems to work:

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

The env DISPLAY=:0 tells it to to export to the display :0 - you can find yours under TTY in the output of w

Then run crontab -e as your normal user where you want the application to run, and paste in this line:

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

If you don't want to to crontab -e to edit it using vim, run this beforehand to use nano instead:

export EDITOR=nano ; export VISUAL=nano

Note the asterisks means it will run every minute, every hour and every day, so it will probably get VERY annoying unless you remove it.

If it still does not work, try running this command:

sudo bash -c "echo $(whoami) > /etc/cron.allow"

And, if you don't want to muck around with text files, you can use gnome-schedule instead.

References:

  • https://help.ubuntu.com/community/CronHowto