[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

find processes by name kill then start again - URGENT

Posted on 2004-08-20
10
Medium Priority
?
762 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 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

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!

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month20 days, 6 hours left to enroll

873 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