编写了一个脚本,该脚本接受用户输入的时间,并且应该在当前时间等于用户输入的时间时终止程序。
它分解为:
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
将 if 语句放在 while 循环中以继续执行脚本,直到当前时间达到所需时间。
我能够运行脚本而没有任何错误,但它根本不会杀死 Chrome。
有小费吗?