Solved

find processes by name kill then start again - URGENT

Posted on 2004-08-20
10
719 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

9 Experts available now in Live!

Get 1:1 Help Now