Linux registration system service registers a system service and starts automatically after it is started. www.2cto. com1 script # vimtest. sh [python] #! /Bin/bash # description: hello. sh # chkconfig: 23452081EXEC_PATH/usr/local/EXEChello. s... the Linux registration system service registers a system service and starts automatically upon startup. www.2cto.com 1 script # vim test. sh [python] #! /Bin/bash # description: hello. sh # chkconfig: 2345 20 81 EXEC_PATH =/usr/local/EXEC = hello. sh DAEMON =/usr/local/hello. sh PID_FILE =/var/run/hello. sh. pid. /etc/rc. d/init. d/functions if [! -X $ EXEC_PATH/$ EXEC]; then echo "ERROR: $ DAEMON not found" exit 1 fi stop () {echo "Stoping $ EXEC... "ps aux | grep" $ DAEMON "| kill-9 'awk' {print $2}''>/dev/null 2> & 1 rm-f $ PID_FILE usleep 100 echo "Shutting down $ EXEC: [OK] "} start () {echo" Starting $ EXEC... "$ DAEMON>/dev/null & pidof $ EXEC> $ PID_FILE usleep 100 echo" Starting $ EXEC: [OK] "} restart () {stop start} case "$1" in Start) start; stop) stop; restart) restart; status) status-p $ PID_FILE $ DAEMON; *) echo "Usage: service $ EXEC {start | stop | restart | status} "exit 1 esac exit $? 2. Register the service # chmod 700 test. sh # cp test. sh/etc/init. d/# chkconfig -- add test. sh # chkconfig -- list 3. delete a service # chkconfig -- del test. sh
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