我已经制作了一个菜单,其中第一个选项是开始,第二个是停止服务,第三个我想开发的是重启服务 将首先停止,然后20秒休息将是theres然后服务将再次启动请告知重启选项,我有代码是否正确.. 我想要一个停车手表也会被调度,这将显示反向计数,如1,然后2然后3,然后在20,它会说启动服务
echo "Please enter the appropriate choice for doing the operations"
echo "
1) STOP Services
2) START Services
3 RestartServices Within 20 seconds
case $choice in
1)
echo "*************Stopping Services**************"
stopAll.sh
;;
2)
echo "*************Starting Services**************"
startAll.sh
;;
3)
echo "*************Restarting services within 20 Seconds*************"
stopAll.sh
sleep 20 seconds //please avise is this this correct way to sleep the services for 20 seconnds..??////
startAll.sh
;;
答案 0 :(得分:1)
从睡眠手册页:
NAME
sleep - delay for a specified amount of time
概要
sleep NUMBER[SUFFIX]... sleep OPTION
说明
Pause for NUMBER seconds. SUFFIX may be 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days. Unlike most implemen‐ tations that require NUMBER be an integer, here NUMBER may be an arbi‐ trary floating point number. Given two or more arguments, pause for the amount of time specified by the sum of their values.
您需要使用sleep 20s
,但s
是默认设置,因此sleep 20
应该有效。