Tuesday, August 6, 2013

Script to know the process id with KEY Name



PROCESS_NAME="Process_name"

PROCESS_ID=`ps -ef | grep -w $PROCESS_NAME | grep -v grep | awk '{print $2}'`

echo $PROCESS_ID

if test "${PROCESS_ID}" != ""
then
echo "Process is already running"

else
  echo "Process is not running"
fi


Note: If multiple processes are running with same KEY name, PROCESS_ID will contain the all process ids.

Ex: 1243 34343 7384 9099 4334

This Script will be useful in cronjob configuration to check any previous process is running before start the new process.


We can configure the process name for cronjob process with –Dapp Key


Ex: java –Dapp=Process_name –jar /data/Weblogic/test.jar

No comments:

Post a Comment