📜  保持服务 2 - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:50:24.288000             🧑  作者: Mango

代码示例1
function finish {
    # re-start service
    sudo service mongdb start
}
trap finish EXIT
# Stop the mongod instance
sudo service mongdb stop
# (If mongod is configured to fork, e.g. as part of a replica set, you
# may instead need to do "sudo killall --wait /usr/bin/mongod".)