Ubuntu 创建开机启动脚本的一种方法(rc.local)

70 篇文章 0 订阅
41 篇文章 0 订阅
#


1、编辑/etc/rc.local
如:sudo vim /etc/rc.local
在 exit 0之前添加脚本代码
如:sh /ect/ifconfig.sh


rc.local:
  1 #!/bin/sh -e
  2 #
  3 # rc.local
  4 #
  5 # This script is executed at the end of each multiuser runlevel.
  6 # Make sure that the script will "exit 0" on success or any other
  7 # value on error.
  8 #
  9 # In order to enable or disable this script just change the execution
 10 # bits.
 11 #
 12 # By default this script does nothing.
 13 
 14 sh /etc/ifconfig.sh
 15 
 16 exit 0




2.在/etc/目录下创建脚本文件(必须在该目录下,其他目录没成功,不知道为什么,希望看见的大神解答下,谢谢)
如:sudo vim ifconfig.sh
  1 
  2 cd /home/sunny/test/ && \
  3 ifconfig > README && \
  4 git add README && \
  5 git commit -m "test2" && \
  6 git push -u origin master


                               
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值