简体   繁体   中英

How to run python script in linux terminal console and continue using command line?

My question seems to be quite easy, but for some reason I did not find a quick answer to it. I have a python script that I want to run on the terminal command line (Ubuntu linux server), which works for me. But then I can't use the command line until the script ends. The script takes a long time to run, and I would like to continue using the command line to perform other tasks. How can you do the work of a script when its progress is not shown on the command line, but keep its work? And how can I see the active processes that are running on the server to see if a process is running?

Run script command: python script.py

Add next with & echo "123" :

在此处输入图像描述

The script takes a long time to run, and I would like to continue using the command line to perform other tasks.

It seems that you want to run said process in background, please try pasting following

python script.py &
echo "123"

it should start your script.py and then output 123 (without waiting until script.py ends)

how can I see the active processes that are running on the server to see if a process is running?

Using ps command

ps -ef

will list all processes which you would probably want to filter to get interested one to you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM