其他分享
首页 > 其他分享> > 10秒钟后自动关机

10秒钟后自动关机

作者:互联网

#!/bin/bash
seconds_left=10
echo "请等待倒计时结束后自动关机..."
while [ $seconds_left -gt 0 ]
do
       echo -n $seconds_left
       sleep 1
       seconds_left=$(($seconds_left - 1))
       echo -ne "\r   \r"
done
shutdown -h now 
#!/bin/bash
read -p "您确定要关机吗?输入yes关机或者其他取消:" down_linux
seconds_left=10
case $down_linux in
"yes")
        echo "系统将在 $seconds_left 秒后关机,请等待倒计时结束后自动关机..."
        while [ $seconds_left -gt 0 ]
        do
                echo -n $seconds_left
                sleep 1
                seconds_left=$(($seconds_left - 1))
                echo -ne "\r   \r"
                        if [ $seconds_left -eq 0 ];then
                                echo `init \0`
                        fi
        done;;
"*")
        echo "您已取消关机。";;
esac

 

标签:10,关机,seconds,秒钟,自动关机,echo,left
来源: https://www.cnblogs.com/liujunjun/p/14420292.html