How to run a command from the terminal/a script without the need to wait until the program exits?

0

1

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?

user1527118

Posted 2013-01-14T19:57:42.520

Reputation:

You could run it in the background, just do: ./command.py & – None – 2013-01-14T20:00:09.873

Answers

2

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

python file.py &

poke

Posted 2013-01-14T19:57:42.520

Reputation: 589

Already tried this but it does not work. – None – 2013-01-14T20:22:11.393

1

Several choices:

  1. Run it in screen. man screen, screen, myprorgamm, C-a d, screen -r.
  2. nohup myprogramm
  3. myprogramm &

iced

Posted 2013-01-14T19:57:42.520

Reputation:

Tried: $ screen _command_, $ nohup _command_ $ _command_ &. Nothing worked so far. – None – 2013-01-14T20:19:21.853

You need to start screen separately first; and if you don’t have screen, install it first. – poke – 2013-01-14T20:20:54.663

1for 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. – None – 2013-01-14T20:23:37.843

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! – None – 2013-01-14T20:32:17.627

0

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

./your_script.py &

Ivan Yurchenko

Posted 2013-01-14T19:57:42.520

Reputation:

Tried that from the terminal but it does not work. – None – 2013-01-14T20:04:35.947

What OS and shell are you using? – None – 2013-01-14T20:05:58.517

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). – None – 2013-01-14T20:13:11.553