linux下Shell编程--标准的守护进程的启动脚本
2015-05-18 13:22
387 查看
一个标准的守护进程的启动脚本:
#! /bin/sh WHOAMI=`whoami` PID=`ps -u $WHOAMI | gerp mydaemond | awk '{print $1}'` if (test "$1" = "") then echo "mydaemond [start][stop][version]" exit 0 fi if ( test "$1" = "status") then if ( test "$PID" = "") then echo "not run" else echo "is running" fi exit 0 fi if (test "$1" = "start") then if (test "$PID" = "") then ./mydaemond fi exit 0 fi if (test "$1" = "stop") then if (test "$PID" = "") then kill $PID fi exit 0 fi if (test "$1" = "version") then echo "version is V1.0" exit 0 fi echo "mydaemond [start][stop][version]"
######################################################################################
第一个shell脚本
#! /bin/sh a=5 b=5 echo a=$a echo b=$b if (test "$a" = "$b") then echo a=b else echo a!=b fi
//使用`符号执行一个命令的例子 #! /bin/sh DATE=`date` echo "today is" $DATE
//用户输入两个数字,计算两个数字的和 #! /bin/sh read a echo 'a=' $a read b echo 'b=' $b c=`expr $a + $b` echo $c
一个循环5次的例子 #! /bin/sh times=0 while [ "$times" != "5" ]; do echo $times times=$[$times + 1] done
//多重分支的例子 #! /bin/sh case "$1" in start) echo "is start" ;; stop) echo "is stop" ;; *) echo "is nothing" esac
相关文章推荐
- Linux下启动C/C++守护进程的bash脚本
- [Linux] Linux 守护进程的启动方法
- Openwrt(linux)启动服务后台进程守护进程
- linux守护进程启动
- Linux下Service守护进程开发和Shell脚本控制Daemon
- linux利用shell实现守护进程的脚本
- Linux守护进程的启动方法
- Linux下添加自定义脚本到开机自启动,标准rpm,举例:设置Apache自启动
- 使用crontab启动脚本守护tomcat进程
- Linux守护进程的启动方法
- python实现Linux启动守护进程
- Linux 守护进程的启动方法
- Linux 守护进程的启动方法
- Linux封装启动和关闭tomcat进程脚本
- python编写借助linux中的xinetd守护进程实现我们的网络程序(select、重定向标准输入输出)
- UNIX高级环境编程: 终端登录过程-远程登录-进程组-Session-Linux启动过程-dup与重定向-守护进程
- 基于android2.3.5系统:Linux如何启动Andriod的守护进程init
- Linux守护进程的启动方法
- Linux 守护进程的启动方法
- Linux守护进程的启动方法