wrote a script that accepts user input for time and is supposed to kill a program when the current time is equal to the time the user input.
it's broken down to:
read -p "Enter when your class ends in the format 00:00 " endclass
echo "We will close your meeting at $endclass"
NOW=$(date +"%H:%M")
while True
do
echo "Waiting for class to end..."
if [ $NOW = $endclass ]
then
pkill Chrome
fi
done
put the if statement inside a while loop to continue executing the script until the current time reaches the desired time.
I am able to run the script without any errors but it does not kill Chrome at all.
any tips?
There are couple of problems with the while-loop:
NOW
variable is not updated inside the loopsleep 1
inside the loop would prevent it from taking up CPU resources (add from flooding stdout with theecho
'd message).Perhaps an alternative to a while-loop would be to add a sleep for the precise number of seconds, for example: