1、在/etc/init.d目录下建一文件如start
vi /etc/init.d/start
内容如下:
#!/bin/sh
#设置环境变量,可以复制/etc/profile文件中的设置
export Java_HOME=/usr/java/jdk1.5
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/mysql.jar:$JAVA_HOME/lib/activation.jar:$JAVA_HOME/lib/dsn.jar:$JAVA_HOME/lib/imap.jar:$JAVA_HOME/lib/mailapi.jar:$JAVA_HOME/lib/pop3.jar:$JAVA_HOME/lib/smtp.jar
export JRE_HOME=/usr/java/jdk1.5/jre
export CATALINA_HOME=/usr/local/tomcat5
export TY_HOME=/usr/local
case “$1” in
start)
echo “Starting tomcat5…”
/usr/local/tomcat5/bin/startup.sh
echo “Starting authdaemond…”
/usr/local/sbin/authdaemond start
echo “Starting imap…”
/etc/init.d/imap start
echo “Starting imaps…”
/etc/init.d/imaps start
echo “Starting apache…”
/usr/local/apache2/bin/apachectl start
;;
stop)
echo “Stopping tomcat5…”
/usr/local/tomcat5/bin/shutdown.sh
echo “Stopping authdaemond…”
/usr/local/sbin/authdaemond stop
echo “Stopping imap…”
/etc/init.d/imap stop
echo “Stopping imaps…”
/etc/init.d/imaps stop
echo “Stopping apache…”
/usr/local/apache2/bin/apachectl stop
;;
*)
echo “Usage tomcat start/stop”
exit 1;;
esac
2、添加start文件的执行权限
chmod +x start
3、添加到自启动文件中,并设置start随系统启动
chkconfig –add start
chkconfig start on