#!/bin/sh ps -ef | grep voucher | grep -v grep | awk ' BEGIN { # Initialization user groups g["user1"]="group_user1" g["user2"]="group_user2" } { User=$1 PID=$2 PPID=$3 Process=$8 # Check to see if PID or PPID are 1 if (PID==1) { printf("The process %s PID %s, so it can t be killed\n",Process,PID) } else { # The process can be killed if (PPID==1) { # Don t kill the PPID, is 1 command=sprintf("echo Please leave the application... | wall -g %s ; sleep 120 ; kill -9 %s\n",g[User],PID) } else { command=sprintf("echo Please leave the application... | wall -g %s ; sleep 120 ; kill -9 %s ; kill -9 %s\n",g[User],PID,PPID) } system(command) } }'