-1

I'm writing a python script that may execute an external bash script. This bash script does something, and after it's done executing, it will kill the python process, and possibly restart the machine.

It is by design that the bash script would kill the python process and restart the machine, but I'm not sure whether it will still continue executing even if it's parent python process dies. Since the machine will restart after the bash script completes, I'm not interested with its output.

Will the bash script still continue running even after the parent python process dies?

timss
  • 9,982
  • 4
  • 34
  • 56
avendael
  • 2,459
  • 5
  • 26
  • 30

2 Answers2

1

If you use:

os.system('/path/to/script.sh &')

or

subprocess.call('/path/to/script.sh &', shell=True)

The process will keep going even if the python script dies.

If you are always going to reboot, let the OS kill the parent and you not worry about it.

korylprince
  • 2,969
  • 1
  • 18
  • 27
0

yes. You can start a child process that can continue to run after the process that started it exited. Here's how without using shell=True or os.system().

Community
  • 1
  • 1
jfs
  • 399,953
  • 195
  • 994
  • 1,670