I have a production server that runs several bash scripts on the local desktop. Two scripts run all the time and don't need to be stopped. I have a third Python script that I need to start at 9AM. It automatically quits at 1:30AM.

If I add the following to my cron file, it successfully launches leafpad.

* * * * * env DISPLAY=:0 leafpad

As an example, this doesn't work:

* * * * * env DISPLAY=:0 /bin/bash

I tried

* * * * * env DISPLAY=:0 /usr/bin/python /scripts/mypython.py

and the script does start (it sends a startup email), but it's not running on the desktop. What am I missing?


leafpad has a GUI, /bin/bash and /usr/bin/python not. You need a terminal emulator, eg lxterm.

* * * * * env DISPLAY=:0 lxterm -e "/bin/bash -c '/usr/bin/python /scripts/mypython.py'"

or a bash:

* * * * * env DISPLAY=:0 lxterm -e "/bin/bash"
  • This didn't work for me. – user38537 Jul 9 '15 at 7:06
  • Which terminal do you use? lxterm? – A.B. Jul 9 '15 at 7:07
  • I use bash. Is that not the terminal? Whatever Ctrl+Alt+T launches is what I use. – user38537 Jul 9 '15 at 7:09
  • bash is a shell, lxterminal is a terminal emulator. You can start a shell inside a terminal. – A.B. Jul 9 '15 at 7:10
  • Okay. I'll keep toying with it. – user38537 Jul 9 '15 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.