I'm trying to make a script that will run a program on parameter. When the program has been executed for 1 minute the program will exit.
My code looks like this:
pid=$(pidof $1)
true=1
$1
while [ $true = 1 ]
do
time=$(ps -p $pid -o etime=)
if $time > 01:00
then
true=0
kill -9 $pid
echo "The process $pid has finish since the execution time has ended"
fi
done
Any ideas? Program lunches but does not quit.