Kill a process from perl script

后端 未结 4 493
自闭症患者
自闭症患者 2021-01-19 05:53

I am trying to kill a process by name which i will pass as a variable to a system command.

Below is what i have:

my $processName=$ARGV[0];
print \"$         


        
4条回答
  •  [愿得一人]
    2021-01-19 06:27

    my $pid = `ps -ef | grep '$processName' | grep -v grep | awk '{print \$2}'`;
    print $pid;
    system("kill -9 $pid");
    

    This one works!!!

提交回复
热议问题