1. 环境
OS: SUSE
Application Server: Websphere 7
2. 准备shell 脚本
启动websphere 服务脚本,命名为websphere
- #!/bin/bash
- #
- #
- #chkconfig: 2345 98 02
- #description: start/stop the websphere
- #
- #/etc/init.d
- #
- startscript=/opt/IBM/WebSphere7/AppServer/bin/startServer.sh
- shutscript=/opt/IBM/WebSphere7/AppServer/bin/stopServer.sh
- #
- PATH=/opt/IBM/WebSphere7/AppServer/java/bin:$PATH
- #
- #FUNCTIONS
- start()
- {
- echo -n $"starting websphere"
- $startscript server1 -profileName AppSrv01
- echo "OK"
- }
- stop()
- {
- echo -n $"stopping websphere"
- $shutscript server1 -profileName AppSrv01 -username admin -password password
- echo "OK"
- }
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- $0 stop
- $0 start
- ;;
- *)
- echo $"usage: $0 {start|stop|restart}"
- exit 1
- esac
- exit 0
3. 拷贝上面脚本到 /etc/init.d 目录,不同linux系统有可能不一样,具体考考个系统的自动加载目录
4. 如果在编写文件的时候不是root用户,那需要赋予shell脚本的执行权力
chmod 755 websphere
5. 加载系统启动项
a. chkconfig --add websphere
添加成功后,可以利用chkconfig --list 来测试是否添加成功
b. 添加启动级别
chkconfig -level 2,3,4,5 websphere on 具体参考不同linux系统格式
6. 测试是否可以启动服务
service websphere start
service websphere stop
7. root用户下,直接reboot启动系统,看是否websphere应用已启动。