gpt4 book ai didi

python - 如何在 linux 终端控制台中运行 python 脚本并继续使用命令行?

转载 作者:行者123 更新时间:2023-12-04 18:58:45 25 4
gpt4 key购买 nike

我的问题似乎很简单,但由于某种原因,我没有找到一个快速的答案。我有一个我想在终端命令行(Ubuntu linux 服务器)上运行的 python 脚本,它对我有用。但是在脚本结束之前我不能使用命令行。该脚本需要很长时间才能运行,我想继续使用命令行执行其他任务。当脚本的进度未显示在命令行上时,您如何执行脚本的工作,但保留其工作?以及如何查看服务器上正在运行的事件进程以查看进程是否正在运行?
运行脚本命令:python script.py添加下一个 & echo "123" :
enter image description here

最佳答案

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


您似乎想在后台运行所述进程,请尝试粘贴以下内容
python script.py &
echo "123"
它应该开始你的 script.py然后输出 123 (无需等到 script.py 结束)

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


使用 ps 命令
ps -ef
将列出您可能想要过滤以引起您兴趣的所有进程。

关于python - 如何在 linux 终端控制台中运行 python 脚本并继续使用命令行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71601989/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com