?
Solved

find processes by name kill then start again - URGENT

Posted on 2004-08-20
10
Medium Priority
?
753 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

777 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