In Linux, general software is started as a service.
Source: Internet
Author: User
In Linux, the general software startup method is used as a service method. the openmeeting installed this time is used as an example: www.2cto.com directory structure:/root/openmeeting_dirnary/admin. batadmin. sh... red5.shred5-shutdown. batred5-shutdown.sh... if you want to start it .. in Linux, general software is started as a service.
Take the openmeeting installed this time as an example:
Www.2cto.com
Directory structure:/root/openmeeting_dirnary/admin. bat
Admin. sh
...
Red5.sh
Red5-shutdown.bat
Red5-shutdown.sh
...
If you want to start it, we usually go to this/root/openmeeting_dirnary/directory,
Run:./red5.sh & (of course, you must have the execution permission)
Now we have to do the following: www.2cto.com
It can be started or closed to form a service... stop | start | restart | status | restart method.
Cd/etc/init. d/
Touch openmeetingd ....)
Paste the code of the file and explain it in detail:
# Start Red5 demon
Start () {# There is nothing to say about this step. it is to enter the Directory, change the permission, and start...
Echo "starting red5 ..."
Cd/root/openmeeting_binary/
Chmod 755 red5.sh
./Red5.sh &
Echo "Red5 started successful ..."
}
# Show the status of red5
Status () {# identify the status by determining whether the process is started, that is, whether the pid exists
Pid = 'PS-ef | grep "java" | grep-v "grep" | awk '{print $2 }''
If ["$ pid" = ""]; then
Echo "red5 is stopped ..."
Else
Echo "red5 is running ..."
Fi
}
# Execute by input command # determine what to execute based on the input command
Case "$1" in
Start)
Start
;;
Stop)
Stop
;;
Status)
Status
;;
Restart)
Restart
;;
*)
Echo $ "Usage: $0 {start | stop | status | restart }"
Exit 1
Esac next we will focus on the script executed during stop:
Pid = 'PS-ef | grep "java" | grep-v "grep" | awk '{print $2} ''to obtain the pid of the process.
Execute ps-ef | grep "java:
This statement mainly finds out the running process of red5, which is java. we can also see that the second process is the grep java we just executed,
To obtain only the preceding row, execute:
Ps-ef | grep "java" | grep-v "grep"
Here we can see that there is only one line left, which is the ID of the red5 survival we want.
The-v parameter of grep indicates that all rows without text are displayed, and the second row is removed.
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.