[root@NFS-Client-01 init.d]# pwd
/etc/init.d
[codesyntax lang=”text” lines=”no”]
#!/bin/bash httpd="/application/apache/bin/httpd -k" # Source function library . /etc/init.d/functions start(){ ? ? ? ?$httpd start >& /dev/null ? ? ? ?[ $? -eq 0 ] && action "Apache is started" /bin/true ||\ ? ? ? ?action "Apache is stopped" /bin/false } stop(){ ? ? ? $httpd stop >& /dev/null ? ? ? [ $? -eq 0 ]&& action "Apache is stopped" /bin/true||\ ? ? ? action "Apache is started" /bin/false } case "$1" in ? ? start) ? ? ? ? ? start ? ? ? ? ;; ? ? stop) ? ? ? ? ?stop ? ? ? ? ;; ? ? restart) ? ? ? ? ?stop ? ? ? ? ?sleep 2 ? ? ? ? ?start ? ? ? ? ?;; ? ? ? ?*) ? ? ? ? ?echo "Uage:$0{start|stop|restart}" ? ? ? ? ?exit ? ? ? ? ;; esac[/codesyntax]
脚本执行:
开发apache启动脚本