CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced: Kill Process in Perl: Edit Log



sha37
Novice

Mar 9, 2010, 12:24 PM


Views: 5175
Kill Process in Perl

Hi Folks,

I have a scheduler shell script. i pass a command to the shell script saying (start and stop)


Code
   

[shap@test]$ sh scheduler.sh start



Inside the shell script


Code
   

#!/bin/sh

if [ -n $1 ];
then
perl AD.pl $1;
fi



The Perl file AD.pl ignores "start" process. But when i pass the shell script "STOP". The perl should kill the process.

I mean the AD.pl should stop running. like forcing it to kill. what is the best way to kill the running process.

in AD.pl the below code i have is


Code
   

if ($ARGV[0] eq 'stop')
{
my $cmd = "ps aux | grep " . $0;
my $result = `$cmd`;
$log->notice("Stopping Follower $followerName");
system(`kill -9 $result`);
exit;
}



This runs well but shows some bunch of errors in the shell script. Is this the best way or can i make it more cleaner?

Thanks in Advance

Sha


(This post was edited by sha37 on Mar 15, 2010, 1:16 PM)


Edit Log:
Post edited by sha37 (Novice) on Mar 15, 2010, 1:16 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives