糊涂记事本
来源: BlogBus 原始链接: http://www.blogbus.com:80/blogbus/blog/diary.php?diaryid=128056 存档链接: https://web.archive.org/web/20041103194814id_/http://www.blogbus.com:80/blogbus/blog/diary.php?diaryid=128056
返回首页 | BLOGBUS JDBC中ResultSet居然没有没有返回结果集数量的函数! 再,斯可矣! 如何远程控制内网机器 三人行 Redhat 9安装OpenLDAP手记 猴年马月就要到了 Tune ClearType settings in WindowsXP 贴张照片玩 设置开机时启动apache服务 设置linux服务自启动 <<<续前 | 返回首页 | 设置开机时启动apache服务>>> 设置linux服务自启动 ktnd 发表于 2004-04-04 两种方法
- 修改rc.local 比如 #sshd /usr/local/sbin/sshd #proftpd /usr/local/sbin/proftpd #apache /home/apache/bin/apachectl start 但是 #tomcat /usr/tomcat/bin/startup.sh 是不起作用的,因为系统初始化过程中JAVA_HOME等环境变量 可以修改catalina.sh添加JAVA_HOME等环境变量
- 创建启动脚本
#!/bin/sh
named This shell script takes care of starting and stopping
named (BIND DNS server).
chkconfig: 345 55 45
description: named (BIND) is a Domain Name Server (DNS) \
that is used to resolve host names to IP addresses.
probe: true
Source function library. 提供后面所用到的函数
. /etc/rc.d/init.d/functions
Source networking configuration. 网络的配置参数,用netconf配置时生成的
. /etc/sysconfig/network
Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0 检查网络是否启动,否就退出 [ -f /usr/sbin/named ] || exit 0 检查BIND主程序是否存在,否就退出 [ -f /etc/named.conf ] || exit 0 检查BIND的配置文件是否存在,否就退出
See how we were called. 检查传入的启动参数
case "$1" in start)
Start daemons. START
echo -n "Starting named: " 显示STARTING NAMED: daemon named 以守护进程方式启动NAMED,成功显示SUCCESS,失败显示FAILD,DAEMON这个函数在. /etc/rc.d/init.d/functions 中 echo touch /var/lock/subsys/named 创建文件锁 ;; stop)
Stop daemons. STOP
echo -n "Shutting down named: " 显示Shutting down named: killproc named 杀掉进程NAMED,成功显SUCCESS,失败显FAILD rm -f /var/lock/subsys/named 删除文件锁 echo ;; status) STATUS /usr/sbin/rndc status 调用BIND的附属程序RNDC显示BIND的状态 exit $? ;; restart) RESTART $0 stop 调用脚本自己停止服务 $0 start 调用脚本自己启动服务 exit $? ;; reload) RELOAD /usr/sbin/rndc reload 调用RNDC重新读入配置文件 exit $? ;; probe) 同上,只是把控制台输出重定向到NULL设备
named knows how to reload intelligently; we don't want linuxconf
to offer to restart every time
/usr/sbin/rndc reload >/dev/null 2>&1 || echo start exit 0 ;; *) 错误的参数就显示参数提示 echo "Usage: named {start|stop|status|restart}" exit 1 esac exit 0
改变脚本权限为可执行,并复制到/etc/init.d/中 chkconfig --add 脚本名
chkconfig: 345 55 45
表示运行级别345下自动启动(/etc/rc.d/下 rc3.d rc4.d rc5.d都用相应链接到init.d/),启动的优先级是55,停止的优先级是45 上面的脚本我也不太懂,先录上,下面是postgresql的启动脚本
#! /bin/sh
chkconfig: 2345 98 02
description: PostgreSQL RDBMS
This is an example of a start/stop script for SysV-style init, such
as is used on Linux systems. You should edit some of the variables
and maybe the 'echo' commands.
Place this file at /etc/init.d/postgresql (or
/etc/rc.d/init.d/postgresql) and make symlinks to
/etc/rc.d/rc0.d/K02postgresql
/etc/rc.d/rc1.d/K02postgresql
/etc/rc.d/rc2.d/K02postgresql
/etc/rc.d/rc3.d/S98postgresql
/etc/rc.d/rc4.d/S98postgresql
/etc/rc.d/rc5.d/S98postgresql
Or, if you have chkconfig, simply:
chkconfig --add postgresql
Proper init scripts on Linux systems normally require setting lock
and pid files under /var/run as well as reacting to network
settings, so you should treat this with care.
Original author: Ryan Kirkpatrick <
$Header: /cvsroot/pgsql-server/contrib/start-scripts/linux,v 1.3 2001/07/30 14:52:42 momjian Exp $
EDIT FROM HERE
Installation prefix
prefix=/usr/local/pgsql
Data directory
PGDATA="/usr/local/pgsql/data"
Who to run pg_ctl as, should be "postgres".
PGUSER=postgres
Where to keep a log file
PGLOG="$PGDATA/serverlog"
STOP EDITING HERE
Check for echo -n vs echo \c
if echo '\c' | grep -s c >/dev/null 2>&1 ; then ECHO_N="echo -n" ECHO_C="" else ECHO_N="echo" ECHO_C='\c' fi
The path that is to be used for the script
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
What to use to start up the postmaster
DAEMON="$prefix/bin/pg_ctl" set -e
Only start if we can find pg_ctl.
test -f $DAEMON || exit 0
Parse command line parameters.
case $1 in start) $ECHO_N "Starting PostgreSQL: "$ECHO_C su - $PGUSER -c "$DAEMON start -D '$PGDATA' -s -l $PGLOG" echo "ok" ;; stop) echo -n "Stopping PostgreSQL: " su - $PGUSER -c "$DAEMON stop -D '$PGDATA' -s -m fast" echo "ok" ;; restart) echo -n "Restarting PostgreSQL: " su - $PGUSER -c "$DAEMON restart -D '$PGDATA' -s -m fast" echo "ok" ;; status) su - $PGUSER -c "$DAEMON status -D '$PGDATA'" ;; *)
Print help
echo "Usage: $0 {start|stop|restart|status}" 1>&2 exit 1 ;; esac exit 0
2004-04-04 | Trackback(0) | 编辑 看了这些文字,有人说了以下一些话: