#!/bin/bash
stats=`ps -ef | grep "a.sh" | grep -v "grep"`
pids=`echo $stats | awk '{print $2}'`
current_pid=$$
for pid in $pids
do
if [ "$pid" != "$current_pid" ]
then
echo "a.sh is running"
exit 1
fi
done
stats=`ps -ef | grep "a.sh" | grep -v "grep"`
pids=`echo $stats | awk '{print $2}'`
current_pid=$$
for pid in $pids
do
if [ "$pid" != "$current_pid" ]
then
echo "a.sh is running"
exit 1
fi
done