Ubuntu - Executing a script at startup and shutdown

[original site]http://ccm.net/faq/3348-ubuntu-executing-a-script-at-startup-and-shutdown
User-defined tasks can be done by executing a script at startup and shutdown for Linux. To execute script at startup of Ubuntu, the rc.local can be modified to include additional commands. To execute script when rebooting Ubuntu, the script has to be copied to the relevant directory. Once the permissions of the script have been changed to executable, it will run when rebooting the Linux operating system. Scripts are run in the alphabetical order in the directories and the scripts should be named following the nomenclature rules when executing a script at startup and shutdown with all distributions of Linux.

To execute a script at startup of Ubuntu

Edit /etc/rc.local and add your commands
The script must always end with exit 0 

To execute a script upon rebooting Ubuntu

Put your script in /etc/rc0.d
Make it executable (sudo chmod +x myscript)
Note: The scripts in this directory are executed in alphabetical order 

The name of your script must begin with K99 to run at the right time.
To execute a script at shutdown

Put your script in /etc/rc6.d
Make it executable (sudo chmod +x myscript)
Note: The scripts in this directory are executed in alphabetical order 

The name of your script must begin with K99 to run at the right time.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值