check process running

I have this script:

-------------------------------------------------------
#!/bin/ksh
#
if [[ -s /usr1/psc_load/infiles/daily/ebods999.ftm ]] ||
[[ -s /usr1/psc_load/infiles/refresh/ebods000.ftm ]]
then
echo "Executing main_load.sh script"
/usr1/psc_load/jobs/cron/main_load.sh "ods"
else
echo "File not found, do nothing"
fi
exit 0

------------------------------------------------------

This script is run as cron every 20 mins.
now I would like it to exit or go to sleep if it finds the process name "load" running.

Please help me

thanks
rose

Welcome to the forum ! :slight_smile:

There are many threads which discuss about using ps -ef to check whether a process is running or not and to take corresponding action with the output of ps -ef

Just a simple search on it would help you :slight_smile:

Thanks for replying. I did search but I didn't find what I want.

Ma'am rose,

$ cat cronstopper
x=load
y=`ps -ef | grep load | awk '{print $9}' |head -1`
if [ $y = $x ]
then
chmod 000 yourscript.sh # reason for this, it wont execute your cron.
else
echo " load is still not running, your cron will still run evry 20 minutes "
fi
$

Thanks

Hi invinzin21,

Thanks for the script. But I want to add the ps command to check if the process name "load" is running to my existing script, something like a loop command, or an if command to check for that "load" process, exit when it finds it, and conitnue to monitor that file again.
so frustrated after so many tries.