0

I run ./install.sh and I tried to background it to be able to close the ssh session.

But after running bg the process is again outputting to the terminal.

Also, I don't see anything with jobs.

And top shows several instances of cc1plus so I am not even sure if running a script actually counts as a process? Maybe it is starting several processes in the process of beeing processed...

bomben
  • 115
  • 9

1 Answers1

1

When you run a Shell/Bash script, the execution of the script is a process. When the script runs other programs, these are also processes. If you run other scripts from your script, depending on how you run them, they may also be their own processes.

For example, if you run ./install.sh and the content is:

#!/bin/bash
...
...
...

Then you will have a bash process running your script. Something like:

ps -ef
joe 345   1   /bin/bash install.sh

345 represents the PID (Process ID) and 1 represents the PID of the parent process.

If your install.sh script then runs, say touch /tmp/myfile then you would have:

ps -ef
joe 345   1   /bin/bash install.sh
joe 346  345  touch /tmp/myfile

As for the output, the Superuser post linked in the comment of the question explains it fairly well so I won't attempt to re-explain it. But the script/program's output is bound to stdout so that comes out on whatever is stdout. If it is the console, so be it. If it's a file, great. In theory if the process is running in the background, and you disconnect from the console and stdout is the console, that should not be a problem, but you will not have any of the output for later review.

ETL
  • 6,513
  • 1
  • 28
  • 48
  • I was confused by the fact that `jobs` does not show any entries. With `ps -ef` I now of course found my `/bin/bash ./install.sh`. Thanks! – bomben Sep 26 '19 at 04:49