Solved

find processes by name kill then start again - URGENT

Posted on 2004-08-20
10
729 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
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 45

Assisted Solution

by:sunnycoder
sunnycoder earned 250 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
notReplace  challenge 53 116
dog bark java program 15 87
difference between String.subString() and String.subSequence() 6 171
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 74
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now