how to start a process and make it sleep for 5 mins and then kill that process
write a script and give sleep function in that.call it with background process by running
scriptname &
while [ 0 -le 5 ] #which is infinite while loop
do
./my_function_which_prints_hi_every_5secs #written in C & stored
sleep 10
killall -9 ./my_function_which_prints_hi_every_5secs #shuld kill program
done
scriptname &; sleep 300; kill $!
I tried this method,still I am getting no process killed. can you justhelp in this
I=1
while [ $I -le 2 ]
do
scriptname &
sleep 10
killall -9 scriptname
echo $I
I=`expr $I + 1`
done
do_something &
sleep 300
kill $!
you havent used kill $! to kill the last background process
use that !
instead of
use
kill $!