Startup script---"Httpd,nginx

Source: Internet
Author: User

#vim httpd.sh

#!/bin/bash
#chkconfig:-45 55
Httpd=/usr/sbin/httpd
Pid=/var/run/httpd/httpd.pid
Start () {
If [-F $pid];then
Echo has started.
Exit
Fi
echo "Starting ..."
$httpd
If [$?-ne 0];then
echo "Failed to start ...."
Else
echo "OK"
Fi
}
Stop () {
if [!-F $pid];then
Echo is closed.
Exit
Fi
echo "Closed ..."
If [-F $pid];then
Kill ' Cat $pid '
echo "Closed successfully ..."
Else
echo "was closed ...."
Fi
}
Status () {
If [-F $pid];then
echo "Staring ..."
Else
echo "is closed ...."
Fi
}
Restart () {
If [-F $pid];then
echo "has been restarted"
Else
$httpd
Fi
}

Case $ in

Start
start;;
Stop
stop;;
Status
status;;
Restart
restart;;
*)
echo "usage is $ {start|stop|restart|status}"
Esac





#vim nginx.sh

#!/bin/bash
#chkconfig:-44 55
Nginx=/usr/sbin/nginx
Pid=/usr/local/nginx/logs/nginx.pid
Start () {
If [-F $pid];then
echo "Already started"
Exit
Fi
echo "Starting ..."
$nginx
If [$?-ne 0];then
echo "Failed to start ...."
Else
echo "started successfully"
Fi
}
Stop () {
if [!-F $pid];then
echo "Closed ..."
Exit
Fi
echo "Closed ..."

If [-F $pid];then
Kill ' Cat $pid '
echo "Closed successfully ..."
Else
echo "would have been closed ..."
Fi
}
Status () {
If [-F $pid];then
echo "Start ..."
Else
echo "Closed ..."
Fi
}
Restart () {
If [-F $pid];then
echo "has been restarted"
Else
$nginx
echo "Reboot succeeded"
Fi
}
Case $ in
Start
start;;
Stop
stop;;
Status
status;;
Restart
restart;;
*)
echo "usage is $ {start|stop|restart|status}"
Esac



#sh nginx.sh Stop

This article is from the "12336621" blog, please be sure to keep this source http://12346621.blog.51cto.com/12336621/1914679

Startup script---"Httpd,nginx

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.