ユーザーのプロセスを終了する[閉じる]

ユーザーのプロセスを終了する[閉じる]
chomp $choice;
if ($choice == 5) {
   print "**********************************\n";
   print " Enter the User Name\n";
   $user_name = <STDN>;

   sub kill_processes {
      $user_name = <STDN> ;
      @process_list = `ps -u $user_name| awk ' { print $2 ;} ' `;
      print @process_list;
      print "Are you sure you want to kill all of these processes? (Y|N) >";
      $resp = <STDIN> ;
      chomp $resp;
      if ( $resp eq "Y" || $resp eq 'y' ) {
         foreach (@process_list) {
            if ( ! /PID/ ) {
               @process = split / /, $_;
               print "Killing Process $process[1]\n";
               `kill -09 $process[1]`;
            }
         }
      }
   }



}

これは私が動作できないコードの一部にすぎません。オプション5を選択するとすべてがうまく機能しますが、ユーザー名を入力しても何もしません。どのように動作させることができますか?

ベストアンサー1

まあ...すでに提供されているコマンドを使用する方が簡単ではないでしょうか?

 killall -u username

もちろん、rootとして実行する必要があります。

おすすめ記事