Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've spent the night trying to figure out how to run a python script in a terminal at startup.

Adding it to init.d will run the script, but I don't see a terminal window or any other indication the script is running other than the audio output the python script produces. I would like to be able to see and interact with this script in a terminal just as if I'd ran it from a terminal.

My next successful step was to make a .desktop file in ~/.config/autostart. My Exec is

Exec=lxterminal -e "python ~/scripts/"

When I log in, I see a terminal window flash for just a brief moment - but then disappear. No sound is produced from the python script so I assume it quit running. How do I start a terminal window at system startup and run a Python script in it?

share|improve this question

It seems your script is running, but you want the term to stay open. If that's the goal:

Exec=lxterminal -e "python ~/scripts/ && /bin/bash"  

Should keep the term open for you...

share|improve this answer

I also had experienced some problems with lxterminal as for calling it with the -e argument from inside a .desktop file.

The solution for me was the following:

  1. Make an executable file, named with the content: lxterminal -e python ~/scripts/

  2. Point to this file at your Exec field of the .desktop file that you have placed

Tips: You can try to directly place in your Exec field lxterminal -e python /home/username/scripts/ Note that it lacks the " and the ~.

Are you sure that python ~/scripts/ doesn't produce any error that causes it to exit?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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