博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ubuntu开机自启动的两种方法总结
阅读量:2120 次
发布时间:2019-04-30

本文共 735 字,大约阅读时间需要 2 分钟。

一.第一种方法

1,新建个脚本文件new_service.sh

#!/bin/bash# command contentexit 0

2,设置权限

sudo chmod 755 new_service.sh

3,把脚本放置到启动目录下

sudo mv new_service.sh /etc/init.d/

4,将脚本添加到启动脚本

执行如下指令,在这里90表明一个优先级,越高表示执行的越晚

cd /etc/init.d/

sudo update-rc.d new_service.sh defaults 90

移除Ubuntu开机脚本

sudo update-rc.d -f new_service.sh remove

一.第二种方法

    

rc.local脚本

rc.local脚本是一个ubuntu开机后会自动执行的脚本,我们可以在该脚本内添加命令行指令。该脚本位于/etc/路径下,需要root权限才能修改。

该脚本具体格式如下:

#!/bin/sh -e## rc.local## This script is executed at the end of each multiuser runlevel.# Make sure that the script will "exit 0" on success or any other# value on error.## In order to enable or disable this script just change the execution# bits.## By default this script does nothing.  exit 0

注意: 一定要将命令添加在 exit 0之前

转载地址:http://tykrf.baihongyu.com/

你可能感兴趣的文章
【Java】【28】提高List的removeAll方法的效率
查看>>
【JS】【31】读取json文件
查看>>
OpenSSL源代码学习[转]
查看>>
Spring下载地址
查看>>
google app api相关(商用)
查看>>
linux放音乐cd
查看>>
GridView+存储过程实现'真分页'
查看>>
flask_migrate
查看>>
解决activemq多消费者并发处理
查看>>
UDP连接和TCP连接的异同
查看>>
hibernate 时间段查询
查看>>
java操作cookie 实现两周内自动登录
查看>>
Tomcat 7优化前及优化后的性能对比
查看>>
Java Guava中的函数式编程讲解
查看>>
Eclipse Memory Analyzer 使用技巧
查看>>
tomcat连接超时
查看>>
谈谈编程思想
查看>>
iOS MapKit导航及地理转码辅助类
查看>>
检测iOS的网络可用性并打开网络设置
查看>>
简单封装FMDB操作sqlite的模板
查看>>