Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The problem is that if I execute a command (eg. a Python script), the terminal or script is waiting until the program return a exit status so that it can continue or return to terminal. Is there a way to circumvent this?

share|improve this question

migrated from stackoverflow.com Jan 14 '13 at 21:53

This question came from our site for professional and enthusiast programmers.

    
You could run it in the background, just do: ./command.py & –  jgr Jan 14 '13 at 20:00
    
Thank jgr for your help. –  user1527118 Jan 14 '13 at 20:37

3 Answers 3

Yes. If you're using Bash or a similar shell, type:

./your_script.py &
share|improve this answer
    
Tried that from the terminal but it does not work. –  user1527118 Jan 14 '13 at 20:04
    
What OS and shell are you using? –  Ivan Yurchenko Jan 14 '13 at 20:05
    
Trisquel GNU/Linux with dash. In Terminal I am using bash, while in scripts dash. Either of these does not work. The command I am trying to execute is /usr/share/screenlets/CircleClock/CircleClockScreenlet.py which is a part of a program called Screenlets (also available in Ubuntu). –  user1527118 Jan 14 '13 at 20:13
    
Thank you. Issue solved! –  user1527118 Jan 14 '13 at 20:36

Several choices:

  1. Run it in screen. man screen, screen, myprorgamm, C-a d, screen -r.
  2. nohup myprogramm
  3. myprogramm &
share|improve this answer
    
Tried: $ screen _command_, $ nohup _command_ $ _command_ &. Nothing worked so far. –  user1527118 Jan 14 '13 at 20:19
    
You need to start screen separately first; and if you don’t have screen, install it first. –  poke Jan 14 '13 at 20:20
1  
for screen - start with man screen, it's complex app with lots and lots of functionality. nohup and & (aka detach) can't "not work", really. if there is any error - make sure to post it here. –  iced Jan 14 '13 at 20:23
    
Hey, the amperstand workaround is working, but for some unknown reason I must double-click on a terminal window because the new line does not show up for some reason. Solved, thank you! –  user1527118 Jan 14 '13 at 20:32

In most shells, you can launch commands or processes in the background by appending an ampersand (&) to the command:

python file.py &
share|improve this answer
    
Already tried this but it does not work. –  user1527118 Jan 14 '13 at 20:22
    
Solved. Thank you for your help. –  user1527118 Jan 14 '13 at 20:36

Your Answer

 
discard

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