[问题]如何开机自动运行一个脚本?

sh/bash/dash/ksh/zsh等Shell脚本
回复
李丑男
帖子: 320
注册时间: 2007-08-29 22:44

[问题]如何开机自动运行一个脚本?

#1

帖子 李丑男 » 2008-04-12 16:20

我用expect写了一个脚本。叫 rj 具体路径放在
/bin/rj
我想让这个脚本在开机的时候自动以root的权限运行。
最好是等到系统启动完之后再自动运行。
头像
bones7456
帖子: 8495
注册时间: 2006-04-12 20:05
来自: 杭州
联系:

#2

帖子 bones7456 » 2008-04-12 17:27

在 /etc/rc.loval 里面加一句就好了。 :lol:
关注我的blog: ε==3
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
联系:

#3

帖子 BigSnake.NET » 2008-04-12 17:29

是 /etc/rc.local

放在exit之前
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
头像
bones7456
帖子: 8495
注册时间: 2006-04-12 20:05
来自: 杭州
联系:

#4

帖子 bones7456 » 2008-04-12 17:30

。。。笔误。 :oops:
关注我的blog: ε==3
李丑男
帖子: 320
注册时间: 2007-08-29 22:44

#5

帖子 李丑男 » 2008-04-12 18:08

是这样子吗?
#! /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
来自: 深圳

#6

帖子 yaoms » 2008-04-14 11:42

你的这个 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
Nothing 有事请发邮件到 yms541 AT gmail.com
alias 爱慕颇雷尔='mplayer'
李丑男
帖子: 320
注册时间: 2007-08-29 22:44

#7

帖子 李丑男 » 2008-04-15 21:44

thank you very much
头像
paulcross
帖子: 484
注册时间: 2006-07-23 20:27

#8

帖子 paulcross » 2008-05-03 8:19

是锐捷上网的脚本吧 呵呵 rj
其实你把它放到/usr/bin 里面
在系统 手选项 对话里面加上一个命令为 rj的项目也可以开机启动的
sivaj
帖子: 541
注册时间: 2007-05-19 16:36

#9

帖子 sivaj » 2008-05-07 19:16

eixt 0表示什么意思 ?
头像
tenfar
帖子: 336
注册时间: 2005-12-10 17:36
来自: 北京市海淀区上地十街辉煌国际
联系:

#10

帖子 tenfar » 2008-05-07 19:34

please paste your code here,thank you!
Laptop:HP Compaq Presario V3210AU
OS:Gentoo openbox+stalonetray+rox-filer+gmrun+mplayer+firefox+ibus+sonata+tilda
Phone:Orange Dopod 838+ SPV C600
OS:Windows Mobile 6.1
spiritfrog
帖子: 274
注册时间: 2007-08-04 13:04

#11

帖子 spiritfrog » 2008-05-14 1:14

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
谢谢,也用这个解决了windows硬盘分区开机自动挂载的问题,
有关于rc的资料吗?网上找的感觉看不大懂。。。
回复