给linux添加服务的步骤: 第一:编写服务脚本,命名为:testService
- start()
- {
- echo “start testService”
- /usr/local/bin/testService & #可执行文件路径
- exit 0;
- }
- stop()
- {
- echo -n “stop testService”
- if pkill testService
- then
- echo ” [ok]”
- else
- echo ” [failed]”
- fi
- }
- case “$1” in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- stop
- start
- ;;
- *)
- echo “usage: $0 start|stop|restart”
- exit 0;
- esac
- [root@~]# service testService start
- uapd: 未被识别的服务
- [root@~]# ll /etc/init.d/testService #检查权限
- ———- 1 root root 1025 08-30 17:47 /etc/init.d/testService #文件权限
- [root@~]#
- [root@~]# chmod 033 /etc/init.d/testService #设置文件权限
- [root@~]# service uapd start
- start testService [确定]
- [root@~]#