Sunday, May 5, 2024
12
rated 0 times [  12] [ 0]  / answers: 1 / hits: 77940  / 3 Years ago, sun, september 26, 2021, 7:47:36

I have a python based server which i start from the terminal. This particular instance of the terminal then gives control to the program, and the program uses it as a kind of logging window, until its closed. Is this normal, or should i somehow try to start the program some other way in which it will simply show as an active process? If i close the terminal from which i started the program, the program dies with it.



Thank you


More From » command-line

 Answers
3

Even old bash is using & for sending processes to background, but there is few other ways too .. but basic two are these :



1.)$~ your_command > outputfile_for_stdout &
# runs your command in background, giving you only PID so you can exit that process by `kill -9 PID_of_process`
# & goes at the end of row


2.)$~ your_command > outputfile_for_stdout
# this will run your program normally
# press Ctrl + Z then program will pause
$~ bg
# now your program is running in background
$~ fg
# now your program came back to foreground
3.)you can run terminal window under screen command so it will live until you either kill it or you reboot your machine
$~ screen
$~ run_all_your_commands
# Ctrl + A + D will then detach this screen
$~ screen -r will reattach it





Some other useful commands :



   $~ jobs
# will show you all processes running right now, but without PID
$~ ps
# will show you all processes for actual terminal window

[#35392] Sunday, September 26, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
feeous

Total Points: 102
Total Questions: 122
Total Answers: 119

Location: Netherlands
Member since Thu, Jul 1, 2021
3 Years ago
feeous questions
Sat, Jul 23, 22, 23:21, 2 Years ago
Mon, Jul 5, 21, 19:59, 3 Years ago
Mon, Aug 16, 21, 11:42, 3 Years ago
Sun, Mar 19, 23, 21:03, 1 Year ago
;