#!/bin/bash
process="$1"
null=/dev/null
if pkill -9 "$process" &> $null ; then
if pgrep "$process" &> $null ; then
echo "$process is still running"
exit 1
fi
echo "$process killed successfully"
exit 0
fi
echo "Process $process not found"
exit 1
Para usar: ./script.sh process1
Para ver a saída de pkill
e pgrep
, remova o respectivo &> $null