Making scripts run at boot time with Debian
来源:互联网 发布:qq刷赞软件 编辑:程序博客网 时间:2024/05/29 03:19
Posted by Steve on Mon 11 Oct 2004 at 13:01
Debian uses a Sys-V like init system for executing commands when the system runlevel changes - for example at bootup and shutdown time.
If you wish to add a new service to start when the machine boots you should add the necessary script to the directory /etc/init.d/. Many of the scripts already present in that directory will give you an example of the kind of things that you can do.
Here's a very simple script which is divided into two parts, code which always runs, and code which runs when called with "start" or "stop".
#! /bin/sh# /etc/init.d/blah## Some things that run alwaystouch /var/lock/blah# Carry out specific functions when asked to by the systemcase "$1" in start) echo "Starting script blah " echo "Could do more here" ;; stop) echo "Stopping script blah" echo "Could do more here" ;; *) echo "Usage: /etc/init.d/blah {start|stop}" exit 1 ;;esacexit 0
Once you've saved your file into the correct location make sure that it's executable by running "chmod 755 /etc/init.d/blah".
Then you need to add the appropriate symbolic links to cause the script to be executed when the system goes down, or comes up.
The simplest way of doing this is to use the Debian-specific command update-rc.d:
root@skx:~# update-rc.d blah defaults Adding system startup for /etc/init.d/blah ... /etc/rc0.d/K20blah -> ../init.d/blah /etc/rc1.d/K20blah -> ../init.d/blah /etc/rc6.d/K20blah -> ../init.d/blah /etc/rc2.d/S20blah -> ../init.d/blah /etc/rc3.d/S20blah -> ../init.d/blah /etc/rc4.d/S20blah -> ../init.d/blah /etc/rc5.d/S20blah -> ../init.d/blah
If you wish to remove the script from the startup sequence in the future run:
root@skx:/etc/rc2.d# update-rc.d -f blah removeupdate-rc.d: /etc/init.d/blah exists during rc.d purge (continuing) Removing any system startup links for /etc/init.d/blah ... /etc/rc0.d/K20blah /etc/rc1.d/K20blah /etc/rc2.d/S20blah /etc/rc3.d/S20blah /etc/rc4.d/S20blah /etc/rc5.d/S20blah /etc/rc6.d/K20blah
This will leave the script itself in place, just remove the links which cause it to be executed.
You can find more details of this command by running "man update-rc.d".
- Making scripts run at boot time with Debian
- Requesting Permissions at Run Time
- Requesting Permissions at Run Time
- (OK) run my script at boot time in android-x86_64 (Chih-Wei Huang)
- Detecting S60 platform version at run time
- QT: load .ui at run time
- Troubleshooting in Office at Run Time
- Configuring Solaris ACPI at boot-time
- Run-time function call tree with gcc
- Making SQLITE/SQLITE3 executable scripts
- Run Time中请求系统权限Requesting Permissions at Run Time
- Liferay 6.0 R2 run log at first time
- Creating and managing container children at run time
- set a cron job to run at a exact time
- 运行时设计(Design at Run-time)
- 运行时设计(Design at Run-time) 新概念
- Windows Mobile Development Making a quality platform one application at a time(zhuan)
- Delete/Run scripts itself
- 8.2.12 drawArc方法:绘制圆弧
- android surfaceview 双线程实现计时的同时 可以随意移动滑块
- 运营商强势入侵路由器市场 或上演新合纵连横
- getchar与EOF
- 能否用一种语言来培养编程思维以及养成世界观
- Making scripts run at boot time with Debian
- NYOJ从小到大排列三个数
- 人同一人同意让他一人同意让他
- Nvelocity使用方法
- 梵蒂冈电饭锅电饭锅电饭锅地方高
- C语言中库函数自带的排序函数qsort
- (鸡血)8个月从CS菜鸟到拿到Google Offer的经历+内推
- 程序员的憋大招
- 学生党福利到!!!VS2013学生免费用