Methods to hibernate a process in a shell script (sleep usage) _linux shell

Source: Internet
Author: User
Tags sleep

Sometimes a shell script is used to execute a series of programs sequentially. Some programs do not immediately exit after the stop, for example, there is a tomcat hung, even with the kill-9 command has not been an instant to end.

So if the shell is not waiting for it to quit and then execute the next line, it's going to be a mess. Just know the original shell can also have sleep parameters.

Copy Code code as follows:

Sleep 1 sleeps 1 seconds
sleep 1s 1 seconds
Sleep 1m 1 min.
Sleeping 1h sleep 1 hours

Use the following, such as restarting Tomcat:

Copy Code code as follows:

#!/bin/sh
/opt/tomcat/bin/shutdown.sh
Sleep 3 #等3秒后执行下一条
/opt/tomcat/bin/startup.sh

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.