Ubuntu编写开机自启动脚本(转载)

From:http://blog.csdn.net/marujunyy/article/details/8466255

1、首先编写一个简单的shell脚本test.sh

#! /bin/bash
echo "Hello world!"
filename=`date"+%Y%m%d"`
echo $filename

2、设置脚本开机自启动

方法一:

  编辑/etc/init.d/rc.local文件,在最后添加编写的脚本即可。

  比如:将/home/test.sh添加为开机自启动

  编辑/etc/init.d/rc.local,在末尾添加如下内容:

sh /home/test.sh

即可开进自动加载脚本

方法二:

  1)将脚本复制到/etc/init.d目录下

  2)修改/etc/init.d/test.sh权限

chmod 755 /etc/init.d/test.sh
update -rc.d test.sh default 95

输字95为脚本启动的顺序号。

 

卸载启动脚本的方法:

cd /etc/init.d

update-rc.d -f test.sh remove

 

posted @ 2014-03-06 23:02  泉水叮~咚  阅读(381)  评论(0编辑  收藏  举报