Six, Shell Script advanced programming combat Part VI

First, write a script start_nginx, when starting, stopping, using the system function to achieve special color effects simulation system startup script (implemented if) reboot   

#!/bin/sh
. /etc/init.d/functions
if [ $# -ne 1 ]
  then
   echo "USAGE $0 {start|stop|restart}"
   exit 1
fi
if [ "$1" == "start" ]
  then
    action "start nginx" /bin/true
elif [ "$1" == "stop" ]
  then
     action "stop nginx" /bin/true
elif [ "$1" == "restart" ]
  then
     action "restart nginx" /bin/true
else
    echo "USAGE $0 {start|stop|restart}"
    exit 1
fi

Test results:

 

Second, what is the function

     Simply put, it is to define the part of the program in multiple calls into one, then a name for all the calls, with the name on it.

    Advantages: reducing the amount of program code; increased readable program readability; modular program functions

Third, to achieve mysql start with if and function

  Single-instance:

        1. Start: mysqld_safe --user = mysql &

 

 

  

 

Guess you like

Origin www.cnblogs.com/dangjingwei/p/11615290.html