Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

find processes by name kill then start again - URGENT

Posted on 2004-08-20
10
Medium Priority
?
760 Views
Last Modified: 2013-12-26
I have some process that need to be restarted. I would like to do this via a script in cron every x minutes.

the files/proces are
iloader0.cgi
iloader1.cgi
iloader2.cgi
iloader3.cgi
iloader4.cgi
iloader5.cgi
iloader6.cgi
iloader7.cgi

I do not know the process id to then kill them.

Can someone tell me the script that will restart these proceses. When restarted the file need to start running in the background all the time until restared.

thanks for any help.

0
Comment
Question by:Nathan_London
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 45

Assisted Solution

by:sunnycoder
sunnycoder earned 750 total points
ID: 11850557
Hi Nathan_London,

killall program_name
will kill all the running instances of a program

restarting a program is just specifying the pathname to the executable
/path/to/iloader0.cgi

to background it, just add a & at the end of the line
/path/to/iloader0.cgi &

Sunnycoder
0
 

Author Comment

by:Nathan_London
ID: 11850771
ok thanks. Still have problem

When i run this script via nohup ./start &
or is that wrong. I need it to run without the shell being open hence nohup

#!/bin/sh
killall iloader0.cgi
killall iloader1.cgi
killall iloader2.cgi
killall iloader3.cgi
killall iloader4.cgi
killall iloader5.cgi
killall iloader6.cgi
killall iloader7.cgi

/www/domain.com/nview/load/iloader0.cgi &
/www/domain.com/nview/load/iloader1.cgi &
/www/domain.com/nview/load/iloader2.cgi &
/www/domain.com/nview/load/iloader3.cgi &
/www/domain.com/nview/load/iloader4.cgi &
/www/domain.com/nview/load/iloader5.cgi &
/www/domain.com/nview/load/iloader6.cgi &
/www/domain.com/nview/load/iloader7.cgi &

These are perl scripts

Only /www/domain.com/nview/load/iloader0.cgi & starts
The others dont start! if i run them without the & it says bad interpretor although I have the path to perl in the perl script. How do i get them all to start?

0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 11850808
>The others dont start! if i run them without the & it says bad interpretor although I have the path >to perl in the perl script.
that's strange
make sure all scripts have execute permissions set

also try specifying perl on the command line

perl /www/domain.com/nview/load/iloader0.cgi &
perl /www/domain.com/nview/load/iloader1.cgi &
etc
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Nathan_London
ID: 11851308
yeah i was using this before. I have changed it to because
killall iloader0.cgi

does not work because perl has started the process
This was only killall perl works
This is not ideal because it kills all perl processes not just the iloaders.

Any other ideas?

N
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 11851857
kill -9 `ps ax | awk '($5~/iloader[0-7]?\.cgi$/){print $1}'`
0
 

Author Comment

by:Nathan_London
ID: 11855092
sytax error

kill: usage: kill [-s sigspec | -n signum | -sigspec] [pid | job]... or kill -l [sigspec]

0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 750 total points
ID: 11855229
did you test what
  ps ax | awk '($5~/iloader[0-7]?\.cgi$/){print $1}'
returns? Please post results if in doubt.
0
 
LVL 6

Expert Comment

by:Talmash
ID: 11862719
hi ,
in perl :
my $jobnum = `echo $$`;
system ("kill $jobnum"); # or killall , or kill -9

try , 1 of the 3 should be sufficient ,

tal
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 11862950
Talmash, your solution could simply be written as:
  exit;
:-))
0
 

Author Comment

by:Nathan_London
ID: 11863774
ahoffmann i did post the results. It errored and gave the usage information. Anyway i sorted it myself now thanks.
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question