vendredi 7 mai 2021

If Statement to Kill Program at User Set Time - Bash

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?

Aucun commentaire:

Enregistrer un commentaire