Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

searching for jobs already running

Status
Not open for further replies.

ianholmes

Programmer
Mar 24, 2001
61
GB
Hi

I have a script which runs a program “JobName”,
with a run-time parameter (A or B).
I take in the parameter, and add “.job” to it before executing it.
I need to enhance my script to check for the job already running with this parameter, and not to attempt to run it if it is already running.

When it runs, if I run :- ps -eaf | grep JobName

I see whoever whenever …path/JobName A.job
& whoever whenever .path/JobName B.job

if they are both running, which is fine.

How do I also identify the “x.job” ?

Help !
 
in your script......$1 is your passed parameter
if grep ${1}.job > /dev/null
then
echo "Job running"
else
echo "Job not running"
do whatever to run the job.....
fi


HTH Dickie Bird (:)-)))
 
Thanks Dickie Bird
I actually take in 3 arguments, say 1, 2 & 3, and construct the passed parameter as 1_2_3.job.

When I run
if ps -eaf | grep ${1}_{2}_{3}.job > /dev/null,
it doesn't work
or even ps -eaf | grep ${${1}_${2}_${3}}.job > /dev/null
or even with " " around the underscores.

What should the syntax be ?
Thanks again.
 
Hmmmmmm.........
I tried :
#!/bin/ksh
if ps -ef|grep $1-$2|grep -v grep
then
echo found
else
echo not found
fi

having 2 params passed in - and it worked fine !
(further piped grep -v to avoid finding the grep command too ! )
Try the grep(with values) at the command line.

HTH


Dickie Bird (:)-)))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top