-1

我已经制作了一个菜单,其中第一个选项是启动,第二个是停止服务,第三个我要开发的是重新启动,其中服务将首先停止,然后会有 20 秒的休息时间,然后服务将是现在重新开始请告知重启选项,我的代码是否正确。我还想显示一个停止手表,它会显示反向计数,如 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

        ;;
4

1 回答 1

1

从睡眠手册页:

姓名

  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应该可以使用。

于 2013-09-22T09:27:39.870 回答