Linux 开机启动websphere 服务

来源:互联网 发布:按键精灵节奏大师源码 编辑:程序博客网 时间:2024/05/22 15:17


1. 环境

    OS: SUSE

    Application Server:  Websphere 7

 

2. 准备shell 脚本

    启动websphere 服务脚本,命名为websphere

 

[plain] view plaincopy
  1. #!/bin/bash  
  2.   
  3. #  
  4.   
  5. #  
  6.   
  7. #chkconfig: 2345 98 02  
  8. #description: start/stop the websphere  
  9.   
  10. #  
  11.   
  12. #/etc/init.d  
  13.   
  14. #  
  15.   
  16. startscript=/opt/IBM/WebSphere7/AppServer/bin/startServer.sh  
  17. shutscript=/opt/IBM/WebSphere7/AppServer/bin/stopServer.sh  
  18.   
  19. #  
  20.   
  21. PATH=/opt/IBM/WebSphere7/AppServer/java/bin:$PATH  
  22.   
  23. #  
  24.   
  25. #FUNCTIONS  
  26.   
  27. start()  
  28. {  
  29.   
  30. echo -n $"starting websphere"  
  31. $startscript server1 -profileName AppSrv01  
  32. echo "OK"  
  33.   
  34. }  
  35.   
  36.   
  37. stop()  
  38. {  
  39.   
  40. echo -n $"stopping websphere"  
  41. $shutscript server1 -profileName AppSrv01 -username admin -password password  
  42. echo "OK"  
  43. }  
  44.   
  45.   
  46. case "$1" in  
  47. start)  
  48.   
  49. start  
  50. ;;  
  51.   
  52. stop)  
  53.   
  54. stop  
  55. ;;  
  56.   
  57. restart)  
  58.   
  59. $0 stop  
  60. $0 start  
  61.   
  62. ;;  
  63.   
  64. *)  
  65.   
  66. echo $"usage: $0 {start|stop|restart}"  
  67.   
  68. exit 1  
  69.   
  70. esac  
  71.   
  72. 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应用已启动。

0 0
原创粉丝点击