
sha37
Novice
Mar 9, 2010, 12:24 PM
Post #1 of 12
(12421 views)
|
Kill Process in Perl
|
Can't Post
|
|
Hi Folks, 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 #!/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 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)
|