分页: 1 / 1
想让命令开机自动运行,要怎么做?
发表于 : 2008-05-23 10:56
由 linunix
我是要运行
/usr/local/gw6c/bin/gw6c
于是把这一行加入了/etc/init.d/rc.local的最后一行,但是无效。
如果手动运行的话,必须得
cd /usr/local/gw6c/bin/gw6c
然后再
sudo ./gw6c
直接运行
sudo /usr/local/gw6c/bin/gw6c的话
就会出现配置文件读取错误。
于是我写了一个shell(自己瞎琢磨的)
内容如下
#!/bin/sh
cd /usr/local/gw6c/bin
./gw6c
cd ~
保存为文件名的gw6c的文件,放在/etc/init.d/目录下。
然后再在/etc/init.d/rc.loca的最后一行加上
/etc/init.d/gw6c
这样似乎就可以了,但是感觉不太好,似乎关机的时候偶尔会提示错误啥的。
请问那个Shell文件要怎么写?
发表于 : 2008-05-23 11:12
由 solcomo
写到rc.local里啊
发表于 : 2008-05-23 11:23
由 yiding_he
发表于 : 2008-05-23 11:24
由 yaoms
$ cat /etc/rc.local
#!/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.
cd /usr/local/gw6c/bin
./gw6c
exit 0
这是我的,没有出错。
发表于 : 2008-05-23 11:28
由 linunix
solcomo 写了:写到rc.local里啊
写到哪个rc.local?
/etc/init.d/rc.local
还是/etc/rc.local?
我写到/etc/init.d/rc.local也不行。
发表于 : 2008-05-23 11:29
由 linunix
这个试过了,不行啊,加了sudo 或gksudo也不行。
发表于 : 2008-05-23 11:30
由 xiehuoli
LS的4樓不是告訴你了嗎?
自己不看?
发表于 : 2008-05-23 11:30
由 yaoms
没看到我的回帖?
发表于 : 2008-05-23 11:31
由 solcomo
就是4楼那样啊
发表于 : 2008-05-23 11:40
由 linunix
yaoms 写了:$ cat /etc/rc.local
#!/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.
cd /usr/local/gw6c/bin
./gw6c
exit 0
这是我的,没有出错。
可以了,谢了。
原来是要添加在/etc/rc.local后面
而不是添加在/etc/init.d/rc.local后面
发表于 : 2008-05-23 11:43
由 linunix
顺便问一个,昨晚我添加了
http://ubuntu.cn99.com/ubuntu-cn/
的源后(用的是软件源的deb命令,而不是修改source.lst文件)
更新了一下,发现关机时不再出现那个进度条画面了,而出了一大串字符界面,似乎是关于network-manager什么的错误。
这是怎么回事?
发表于 : 2008-05-23 11:50
由 linunix
yaoms 写了:没看到我的回帖?
对不起啊,没想到大家这么热情,我刚才是因为在重启试你这个办法,所以迟回复了,不通用的办法我就先回复了。
发表于 : 2008-05-23 13:14
由 bones7456