pythonpowershell

PowerShell equivalent of Linux `nohup command &` - Run processes that survive terminal closure


I need to run Python programs that continue running even after I close the PowerShell terminal window. In Linux bash, I use:

nohup python my_program.py &

This runs the program in the background and it survives terminal closure.

What is the PowerShell equivalent of nohup command &?

What I've tried:

Requirements:


Solution

  • Use the Start-Process cmdlet via conhost.exe, which on Windows launches an independent process in a new console window (by default), use the -WindowStyle parameter to control the visibility / state of that window; e.g., to launch in a hidden window:

    Start-Process -WindowStyle Hidden conhost.exe 'python my_program.py'
    

    Note: