Mar 9, 2010, 12:24 PM
Post #1 of 12
Kill Process in Perl
I have a scheduler shell script. i pass a command to the shell script saying (start and stop)
[shap@test]$ sh scheduler.sh start
Inside the shell script
if [ -n $1 ];
perl AD.pl $1;
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
if ($ARGV eq 'stop')
my $cmd = "ps aux | grep " . $0;
my $result = `$cmd`;
$log->notice("Stopping Follower $followerName");
system(`kill -9 $result`);
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
(This post was edited by sha37 on Mar 15, 2010, 1:16 PM)