Linux添加自启动程序
我们希望在系统自动的时候,启动我们的一些程序,如何做呢?
- 将程序制作为linux的一个服务
- 通过 /etc/rc.local
- 通过 cron的@reboot
第一个的想法是来自一些经典的程序,如httpd,被做成服务,然后可以通过 chkconfig这样的工具来管理,不过有点杀鸡用牛刀的感觉了。我们就使用第二种和第三种吧:
修改 /etc/rc.local
这个文件如果之前没有添加任何内容的话,初始是这样:
1 #!/bin/sh
2 #
3 # This script will be executed *after* all the other init scripts.
4 # You can put your own initialization stuff in here if you don't
5 # want to do the full Sys V style init stuff.
6
7 touch /var/lock/subsys/local
我们只需要将我们要开机自动运行的程序添加的到最后就好。
/path/to/your_app
这种方法在 fedora系列的linux中不可行,请使用下面的方法,或者上面提到的sevice的方法。
cron的@reboot
crontab -e
@boot /path/to/your_app
不管是那种方式,请记住你的程序是读写权限是755
$ chmod 755 /path/to/your_app
版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章出处,否则按侵权处理.