#!bin/bash set -e # Check if user is root if [ $(id -u) != "0" ]; then echo "Error: please use root to install" exit 1 fi id -u www >& /dev/null if [ $? -ne 0 ]; then groupadd www useradd -g www -M -s /sbin/nologin www fi PHP_IN
一.我们先看看编写的shell脚本的内容,该shell的作用主要是实现监控某个程序崩溃之后就自动重启该进程. while true do procnum=` ps -ef|grep "test"|grep -v grep|wc -l` if [ $procnum -eq 0 ]; then /home/test& fi sleep 30 done -eq意思是等于0,用于判断该test是否还在运行状态.监控/home/test这个程序是否运行. 二.由于该程序是window上的
写在前面:案例.常用.归类.解释说明.(By Jim) 使用函数 #!/bin/bash # testing the script function myfun { echo "This is an example of a function" } count=1 while [ $count -le 5 ] do myfun count=$[ $count +1 ] done echo "This is the end of the loop" myfun ech