I have a shell script scheduler.sh passing command line arguments start and stop. Below is the code.
[shap@test]$ sh scheduler.sh stop
If i pass stop the AD.pl file should stop running by killing its pid.
Below is the code for AD.pl when it sees Stop from shell.
Please suggest a cleaner way to above code. is the way i am doing is correct?
Is there a cleaner way of doing it.
Thanks in advance
Sha
Code:
#!/bin/sh
if [ -n $1 ];
then
perl AD.pl $1;
fi
If i pass stop the AD.pl file should stop running by killing its pid.
Below is the code for AD.pl when it sees Stop from shell.
Code:
if ($ARGV[0] eq 'stop')
{
my $cmd = "ps aux | grep " . $0;
my $result = `$cmd`;
$log->notice("Stopping Follower $followerName");
system(`kill -9 $result`);
$signal = 0;
}
Is there a cleaner way of doing it.
Thanks in advance
Sha
Comment