Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash shell脚本中一个进程的休眠_Bash_Shell_Unix - Fatal编程技术网

Bash shell脚本中一个进程的休眠

Bash shell脚本中一个进程的休眠,bash,shell,unix,Bash,Shell,Unix,我制作了一个菜单,其中第一个选项是启动,第二个选项是停止服务,第三个选项是重启服务 将首先停止,然后中断20秒,然后服务将再次启动。现在请告知重新启动选项,我的代码是否正确。。 我想要一个秒表也将显示反向计数,如1,然后2,然后3,然后在20它会说开始服务 echo "Please enter the appropriate choice for doing the operations" echo " 1) STOP Services 2) START

我制作了一个菜单,其中第一个选项是启动,第二个选项是停止服务,第三个选项是重启服务 将首先停止,然后中断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

        ;;

从睡眠手册页:

名字

  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 20s
应该可以工作。

我认为应该是“sleep 20s”,你甚至不想在谷歌上搜索你的疑问,你只是在这个网站上提出疑问:,另一个问题已经被你删除了。而且你不接受任何答案。我认为你应该先尝试解决这个问题或者自己寻找解决方案,然后再问这个问题。