[问题]如何开机自动运行一个脚本?
-
- 帖子: 320
- 注册时间: 2007-08-29 22:44
[问题]如何开机自动运行一个脚本?
我用expect写了一个脚本。叫 rj 具体路径放在
/bin/rj
我想让这个脚本在开机的时候自动以root的权限运行。
最好是等到系统启动完之后再自动运行。
/bin/rj
我想让这个脚本在开机的时候自动以root的权限运行。
最好是等到系统启动完之后再自动运行。
- bones7456
- 帖子: 8495
- 注册时间: 2006-04-12 20:05
- 来自: 杭州
- 联系:
- BigSnake.NET
- 帖子: 12522
- 注册时间: 2006-07-02 11:16
- 来自: 廣州
- 联系:
- bones7456
- 帖子: 8495
- 注册时间: 2006-04-12 20:05
- 来自: 杭州
- 联系:
-
- 帖子: 320
- 注册时间: 2007-08-29 22:44
是这样子吗?
#! /bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
[ -f /etc/default/rcS ] && . /etc/default/rcS
. /lib/lsb/init-functions
do_start() {
if [ -x /etc/rc.local ]; then
log_begin_msg "Running local boot scripts (/etc/rc.local)"
/etc/rc.local
log_end_msg $?
fi
}
case "$1" in
start)
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
;;
*)
echo "Usage: $0 start|stop" >&2
/bin/rj
exit 3
;;
esac
可是这样子不行啊?
#! /bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
[ -f /etc/default/rcS ] && . /etc/default/rcS
. /lib/lsb/init-functions
do_start() {
if [ -x /etc/rc.local ]; then
log_begin_msg "Running local boot scripts (/etc/rc.local)"
/etc/rc.local
log_end_msg $?
fi
}
case "$1" in
start)
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
;;
*)
echo "Usage: $0 start|stop" >&2
/bin/rj
exit 3
;;
esac
可是这样子不行啊?
- yaoms
- 帖子: 4952
- 注册时间: 2007-10-19 14:51
- 来自: 深圳
你的这个 rc.local有问题哦,是 /etc/rc.local吗?
发现你的这个是 /etc/init.d/rc.local .....
请加在 /etc/rc.local 中的 exit 之前:
发现你的这个是 /etc/init.d/rc.local .....
请加在 /etc/rc.local 中的 exit 之前:
代码: 全选
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/bin/rj
exit 0
Nothing 有事请发邮件到 yms541 AT gmail.com
alias 爱慕颇雷尔='mplayer'
alias 爱慕颇雷尔='mplayer'
- paulcross
- 帖子: 484
- 注册时间: 2006-07-23 20:27
- tenfar
- 帖子: 336
- 注册时间: 2005-12-10 17:36
- 来自: 北京市海淀区上地十街辉煌国际
- 联系:
-
- 帖子: 274
- 注册时间: 2007-08-04 13:04
谢谢,也用这个解决了windows硬盘分区开机自动挂载的问题,yaoms 写了:你的这个 rc.local有问题哦,是 /etc/rc.local吗?
发现你的这个是 /etc/init.d/rc.local .....
请加在 /etc/rc.local 中的 exit 之前:代码: 全选
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. /bin/rj exit 0
有关于rc的资料吗?网上找的感觉看不大懂。。。