Shell programming under Linux--startup script for the standard daemon

Source: Internet
Author: User

















a standard daemon startup script:

#! /bin/shwhoami= ' WhoAmI ' pid= ' ps-u $WHOAMI | Gerp Mydaemond | awk ' {print $ ' if (test "=") Thenecho "Mydaemond [Start][stop][version]" Exit 0fiif (Test "=" status ") thenif (test "$PID" = "") Thenecho "not run" Elseecho "is Running" fiexit 0fiif (test "=" Start ") thenif (test" $PID "=" ") th  En./mydaemondfiexit 0fiif (Test "=" "Stop") thenif (test "$PID" = "") Thenkill $PIDfiexit 0fiif (test "$" = "version") Thenecho "version is V1.0" Exit 0fiecho "Mydaemond [Start][stop][version]"

######################################################################################First shell script
#! /bin/sha=5b=5echo a= $aecho b= $bif (test "$a" = "$b") then        echo A=belse        echo A!=BFI

Example of using a ' symbol to execute a command #! /bin/shdate= ' Date ' echo "Today is" $DATE

User inputs Two numbers, calculates two numbers and #! /bin/shread Aecho ' a= ' $aread becho ' b= ' $BC = ' expr $a + $b ' echo $c

An example of a loop 5 times #! /bin/shtimes=0while ["$times"! = "5"];d o        echo $times        times=$[$times + 1]done

Examples of multiple branches #! /bin/shcase "$" instart)        echo "is start"        ;; Stop)        echo "is stop"        ;; *)        echo "Is Nothing" Esac



Shell programming under Linux--startup script for the standard daemon

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.