Write code that allows the program to run even if you turn off the terminal.
nohup (execution code) & You can use nohup with. Below is an example of executing ./a.out.
C:>nohup ./a.out &
The output is written to nohup.out. Once you type the command, execution continues even if you turn off the terminal.
Also, if you want to specify a specific output file, nohup (execution code)> (output file) & Is. An execution example is written below. Write the output of ./a.out to out.txt.
C:>nohup ./a.out >out.txt &
ps x After kill (PID) do. An example is written below.
C:>nohup ./a.out &
C:>ps x
PID TTY STAT TIME COMMAND
5915 -- -- -:-- ./a.out
C:>kill 5915
By doing as above, the execution ends in the middle.
The method is as follows.
C:>nohup python a.py &
The above example is running a.py.
Or as follows.
C:>nohup python a.py >a.txt &
The above example writes the output of a.py to a.txt.
Recommended Posts