相关疑难解决方法(0)

快速而又脏的方法,确保一次只运行一个shell脚本实例

确保在给定时间只运行一个shell脚本实例的快速而简单的方法是什么?

bash shell lockfile process

174
推荐指数
16
解决办法
10万
查看次数

如何检查我的shell脚本的另一个实例是否正在运行

GNU bash,版本1.14.7(1)

我有一个脚本被称为" abc.sh"我必须从abc.sh脚本中检查这个...在其中我写了以下语句

status=`ps -efww | grep -w "abc.sh" | grep -v grep | grep -v $$ | awk '{ print $2 }'`
if [ ! -z "$status" ]; then
        echo "[`date`] : abc.sh : Process is already running"
        exit 1;
fi
Run Code Online (Sandbox Code Playgroud)

我知道这是错的,因为每次它退出,因为它在'ps'中找到了自己的进程如何解决它?如何检查脚本是否已经运行from that script

bash shell concurrency

34
推荐指数
8
解决办法
8万
查看次数

标签 统计

bash ×2

shell ×2

concurrency ×1

lockfile ×1

process ×1