检查指定名称的屏幕是否存在 [英] Checking if a Screen of the Specified Name Exists

查看:55
本文介绍了检查指定名称的屏幕是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经制作了一个bash文件,该文件将在一个具有唯一名称的分离屏幕中启动另一个bash文件,我需要确保该内部bash文件的仅一个实例在任何时间点都在运行.为此,我想在尝试创建父bash文件之前检查该名称的屏幕是否存在.有没有办法做到这一点?

I have made a bash file which launches another bash file in a detached screen with a unique name, I need to ensure that only one instance of that internal bash file is running at any one point in time. To do this, I want to make the parent bash file check to see if the screen by that name exists before attempting to create it. Is there a method to do this?

推荐答案

您可以grep screen -list的输出作为要检查的会话的名称:

You can grep the output of screen -list for the name of the session you are checking for:

if ! screen -list | grep -q "myscreen"; then
    # run bash script
fi

这篇关于检查指定名称的屏幕是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆