The ubuntu/bin/sh of the pit daddy

Source: Internet
Author: User

Wrote a script to stop MongoDB, the code snippet is as follows:

1#!/bin/Bash2 3 # Stop MONGO4Echo"Stop MongoDB ..."5Mongo_pid= ' Ps-ef | grep Mongod | Grep-v grep | Awk'{print $}'`6 if[[A${mongo_pid} = = A"' ]]7  Then8Echo"MongoDB is not running ..."9 ElseTenKill-2${mongo_pid} OneSleep5 A     ifPs-ef | Grep-v grep | grep-Q Mongod -  Then -Echo"MongoDB Stop failed" the     Else -Echo"MongoDB Stop Successful" - fi -Fi

The execution method is

SH stop.sh

Perform normally on CentOS and execute on Ubuntu with an error:

Hey i'm wondering, Brother's code is right Ah, find a half-day did not find the reason, help StackOverflow, find the reason:

Swap with the following script execution method will not be an error

./stop.sh

Check out what Dash is:

In Debian and Ubuntu,/bin/sh is already pointing to dash, which is a different shell from bash, which is mostly for scripting, not interactive, it's faster, but it's much less powerful than bash, and the syntax adheres to the POSIX standard.
Ubuntu with less, pit big, record under

The ubuntu/bin/sh of the pit daddy

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.