tomcatControl.sh部分:
#!/bin/sh
#Ubuntu下Tomcat自动启动
#1:首先安装自启动管理工具
# apt-get install sysv-rc-conf
#2:追加Tomcat启动脚本
# 创建tomcatControl的脚本文件,并放置到/etc/init.d/下,
# 注意文件权限设置为755。脚本内容如下:
export Java_HOME=/usr/local/Easiware/jdk1.5.0_09
case $1 in
startup)
sh /opt/apache-tomcat-5.5.20/bin/startup.sh
;;
shutdown)
sh /opt/apache-tomcat-5.5.20/bin/shutdown.sh
break
;;
restart)
sh /opt/apache-tomcat-5.5.20/bin/shutdown.sh
sh /opt/apache-tomcat-5.5.20/bin/startup.sh
;;
*)
sh /opt/apache-tomcat-5.5.20/bin/startup.sh
;;
esac
exit 0
#3: 执行自启动命令
# sysv-rc-conf tomcatControl on
# 关闭自动启动:
# sysv-rc-conf tomcatControl off
#4: 重新启动:reboot
注意事项: 【Linux公社 】
1、也可以使用如下命令加入自动启动:
1) update-rc.d tomcat安装目录 defaults
2) update-rc.d tomcat安装目录 remove
2、如果提示找不到sysv-rc-conf
apt-get install sysv-rc-conf
3、如果本地设置没有设置好,Per会给出下面的错误提示:
1. perl: warning: Setting locale failed.
2. perl: warning: Please check that your locale settings:
3. LANGUAGE = (unset),
4. LC_ALL = (unset),
5. LANG = "zh_CN.UTF-8"
6. are supported and installed on your system.
7. perl: warning: Falling back to the standard locale ("C").
8. locale: Cannot set LC_CTYPE to default locale: No such file or directory
9. locale: Cannot set LC_MESSAGES to default locale: No such file or directory
10. locale: Cannot set LC_ALL to default locale: No such file or directory
解决办法:
我们只需要执行以下命令就OK了
1. root@idealserver:~# apt-get install locales
2. root@idealserver:~# dpkg-reconfigure locales
3. root@idealserver:~# locale
#其实有个很简单的开机自动启动的方法:
将tomcat的启动脚本命令如本例中:/opt/apache-tomcat-5.5.20/bin/startup.sh
放进/etc/rc.local文件下即可,注意命令脚本需要放在 exit 0 之前。