How can i let the BASH script run as process? So that even the Python script is killed the BASH script runs forever?
Question: I need to track and launch few BASH scripts as process (if they for some
reason crashed or etc). So i was trying as below: but not working

    
    
      def ps(self, command):
        process = subprocess.Popen(['/bin/bash'], shell=False, stdin=subprocess.PIPE,  stdout=subprocess.PIPE)
        process.stdin.write(command + '\n')
        process.stdout.readline()
    
      ps("/var/tmp/KernelbootRun.sh")
      ps("ps aux | grep processCreator.py | awk '{print $2}' | xargs kill -9")
    

None is working.


Answer: How about running it through a subshell with disown:

    
    
    import os
    def ps(self, command):
      os.system(command + " & disown")
    
    ps("/var/tmp/KernelbootRun.sh")
    ps("ps aux | grep processCreator.py | awk '{print $2}' | xargs kill -9")
    

Note that sometimes you have to use a null input and output to keep your
process active when the terminal is closed:

    
    
    ps("</dev/null /var/tmp/KernelbootRun.sh >/dev/null 2>&1")
    ps("</dev/null ps aux | grep processCreator.py | awk '{print $2}' | xargs kill -9 >/dev/null 2>&1")
    

Or perhaps define another function:

    
    
    def psn(self, command):
      os.system("</dev/null " + command + " >/dev/null 2>&1 & disown")
    
    psn("/var/tmp/KernelbootRun.sh")
    psn("ps aux | grep processCreator.py | awk '{print $2}' | xargs kill -9")
    

