gpt4 book ai didi

linux - 如何检查屏幕后台脚本进程?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:49:27 24 4
gpt4 key购买 nike

我有一个在 AWS 服务器后台运行的 shell 脚本。为此,我使用了以下命令:

apt-get install screen   #Install screen
screen -m #Start screen
bash myscript.sh #Run the script
CTRL + a and then d #Detach and run in background

要检查脚本以查看它是否仍在运行,我使用以下命令:

# List the detached screens
screen -ls

# Find the screen to reattach and attach
screen -r 123456

是否有更优雅的方式来查看我的后台脚本是否仍在运行并且没有挂起或处于错误状态?

最佳答案

您可以使用 pgrep <process_name>检查您的脚本是否仍在运行。

pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. All the criteria have to match.

http://linux.die.net/man/1/pgrep

关于linux - 如何检查屏幕后台脚本进程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33325220/

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