GUI with cron

Start a desktop program from cron.

To put a command in your crontab that starts a GUI process on the desktop, set DISPLAY:=0 before it. For example, to launch Dropbox:
export DISPLAY=:0 && dropbox start

In my crontab there is a line that restarts Dropbox every 10 minutes (when Dropbox is not running). Because it happened a few times that when I put more than a few gigabytes of new files in my Dropbox folder, Dropbox stopped with an error message. And you only find out after a while. With this crontab line you don't have to worry about it anymore.
0,10,20,30,40,50 * * * * export DISPLAY=:0 && dropbox start
It launches Dropbox nicely and it Dropbox icon on the taskbar is now always there. Phew, solved!

How to use

Place the script in a file and make it executable with:
chmod +x 
Run the script from inside a terminal window:


Put this script in crontab so that it runs automatically periodically:
crontab -e
View 42 more scripts