Skip to content
August 15, 2016 / doganay

“IS MY SCRIPT RUNNING” SHELL SCRIPT CODE PIECE

## 1 process for script, 1 process for this ps output:
if [[ $(ps -ef|grep $(echo "$0"|awk -F"/" '{print $NF}')|grep -v grep|wc -l) -gt 2 ]]
then
 echo "$0 is already running"
 exit 1
fi
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: