首页 > 系统相关 >一个shell脚本文件名的坑

一个shell脚本文件名的坑

时间:2023-01-26 10:44:06浏览次数:58  
标签:脚本 shell grep 文件名 pid redis sh

shell脚本文件名中不要包含要grep的进程名,比如下面grep了redis,那么文件名中不要包含redis,否则会出问题,因为打开文件的句柄中也包含redis

redis.sh

#!/bin/bash
pid_count=`ps -ef|grep redis|grep -v grep`
echo ${pid_count}

 

sh redis.sh,会有两个sh执行shell文件的进程

 

可以这样命名:startRedis.sh

 

【bak】

原文已更新:https://www.cnblogs.com/uncleyong/p/17067609.html

 

标签:脚本,shell,grep,文件名,pid,redis,sh
From: https://www.cnblogs.com/uncleyong/p/17067609.html

相关文章