linux系统增加开机启动服务/应用
操作
在/etc/init.d下新建示例脚本文件(customize.sh),该脚本会启动zookeeper服务。内容如下:
#!/bin/sh /usr/local/zookeeper-3.4./bin/zkServer.sh start
执行如下命令将customize.sh脚本添加到系统服务中。
root@jacob-PC:~# chkconfig --add customize.sh
insserv: warning: script 'K01customize.sh' missing LSB tags and overrides
insserv: warning: script 'customize.sh' missing LSB tags and overrides
customize.sh :off :off :on :on :on :on :off
root@jacob-PC:~# chkconfig customize.sh on
insserv: warning: script 'K01customize.sh' missing LSB tags and overrides
insserv: warning: script 'customize.sh' missing LSB tags and overrides
jacob@jacob-PC:/etc/init.d$ chkconfig
acpid on
alsa-utils on
avahi-daemon on
bluetooth on
bumblebeed on
cron on
cryptdisks on
cryptdisks-early on
cups on
customize.sh
dbus on
dnsmasq on
docker on
hwclock.sh on
ipsec off
kmod on
lightdm on
lvm2 on
lvm2-lvmetad on
lvm2-lvmpolld on
mdadm on
mdadm-waitidle off
mysql on
network-manager on
networking on
nmbd on
nscd on
open-vm-tools on
openvpn off
plymouth on
plymouth-log on
pppd-dns on
procps on
rcS off
redis-server on
samba-ad-dc on
smbd on
sudo off
udev on
x11-common on
xl2tpd off
如果没有安装chkconfig,可以自行安装一个,例如:ubuntu或deepin系统可以采用下面命令
sudo apt-get install chkconfig
原理
通过chkconfig命令将自定义的sh脚本添加到系统的服务当中。
root@jacob-PC:~# chkconfig --add customize.sh
insserv: warning: script 'K01customize.sh' missing LSB tags and overrides
insserv: warning: script 'customize.sh' missing LSB tags and overrides
customize.sh :off :off :on :on :on :on :off
增加服务时,会提示0-6的一些状态,实际上这些是对应于 /etc/rc*.d的目录。
root@jacob-PC:/etc# ls -l | grep rc
-rw-r--r-- root root 3月 : bash.bashrc
-rw-r--r-- root root 3月 : drirc
-rw-r--r-- root root 3月 : inputrc
-rw-r--r-- root root 4月 mecabrc
-rw-r--r-- root root 3月 : nanorc
drwxr-xr-x root root 3月 : ODBCDataSources
drwxr-xr-x root root 3月 : rc0.d
drwxr-xr-x root root 3月 : rc1.d
drwxr-xr-x root root 3月 : rc2.d
drwxr-xr-x root root 3月 : rc3.d
drwxr-xr-x root root 3月 : rc4.d
drwxr-xr-x root root 3月 : rc5.d
drwxr-xr-x root root 3月 : rc6.d
drwxr-xr-x root root 3月 : rcS.d
-rw-r--r-- root root 3月 : wgetrc
#0 ——停机(不能使用)
#1——单用户模式
#2——多用户模式,但是没有NFS
#3——完全多用户模式
#4——没有使用
#5——图形界面模式
#6——重启模式(不能使用)
对于这几个目录的解释,有几篇文章可以参考:
https://blog.csdn.net/feiyinzilgd/article/details/5750168
文章里说cat /etc/inittab里面存放了默认的启动模式,但是我deepin系统好像没有这个文件,也不打算深究了。
linux系统增加开机启动服务/应用的更多相关文章
- Linux系统入门---开机启动流程
目录 Linux系统入门---开机启动流程 一.centos6 二.systemd管理进程 1.查看级别 三.centos7实践案例: 1.案例1:centos7系统,单用户修改root密码 案例2: ...
- Linux系统的开机启动顺序
Linux系统的开机启动顺序加载BIOS–>读取MBR–>Boot Loader–>加载内核–>用户层init一句inittab文件来设定系统运行的等级(一般3或者5,3是多用 ...
- 不同linux系统添加开机启动程序的命令
see http://phpcj.org/blog/%E4%B8%8D%E5%90%8Clinux%E7%B3%BB%E7%BB%9F%E6%B7%BB%E5%8A%A0%E5%BC%80%E6%9C ...
- linux chkconfig添加开机启动服务
--add:增加所指定的系统服务,让chkconfig指令得以管理它,并同时在系统启动的叙述文件内增加相关数据: --del:删除所指定的系统服务,不再由chkconfig指令管理,并同时在系统启动的 ...
- NO19 优化Linux系统--重要开机自启动服务--关闭自启动项
**如何优化Linux系统: 1 不用root,添加普通用户,通过sudo授权管理.2 更改默认的远程连接SSH服务端口及禁止root用户远程连接.3 定时自动更新服务器时间.4 配置 ...
- 基于Linux Shell的开机启动服务
CentOS重启后,很多服务需要手动启动,很是麻烦,今天把需要开机启动或关闭的服务整理了一下,放入Linux Shell中,再将该Shell加入/etc/rc.local中,即可实现存储的自动挂载.S ...
- linux系统下开机启动流程
在了解开机启动流程之前,还是得先了解一些磁盘的基本知识.磁盘主要由盘片,机械手臂,磁头,主轴马达构成.盘片就是存储数据的物理单位了.然后盘片上我们可以分成扇区(sector)和柱面(cylinder) ...
- linux自定义开机启动服务和chkconfig使用方法
linux自定义开机启动服务和chkconfig使用方法 1. 服务概述在linux操作系统下,经常需要创建一些服务,这些服务被做成shell脚本,这些服务需要在系统启动的时候自动启动,关闭的时候自动 ...
- (转)linux自定义开机启动服务和chkconfig使用方法
原文:https://www.cnblogs.com/jimeper/archive/2013/03/12/2955687.html linux自定义开机启动服务和chkconfig使用方法 1. 服 ...
随机推荐
- [HNOI2015]亚瑟王
题面在这里 题意 \(n\)张卡按照一定顺序排列,每轮从第\(1\)张开始考虑到最后一张,考虑一张卡时有\(p[i]\)的概率产生\(d[i]\)的贡献,产生贡献时直接退出该轮并在之后的考虑中直接跳过 ...
- Bzoj1176:Mokia&Cogs1752:[BOI2007]摩基亚Mokia
题目 Cogs 没有Bzoj的权限号 Sol 离线,\(CDQ\)分治,把询问拆成\(4\)个,变成每次求二位前缀和 那么只要一个修改操作(关键字为时间,\(x\),\(y\))都在这个询问前,就可以 ...
- Django的models实现分析
1 引子 1.1 神奇的Django中的models 我们先来看一段在Django项目中常用的代码: 设置数据库models代码: class Students(models.Mod ...
- Delphi的RzDbgrid改变某行的背景色
本想改变符合条件的行的背景色,试了DbgridEh和原生的Dbgrid直接在DrawColumnCell事件中写重绘代码就好了,But在RzDbgrid就不起效果,查了好一会,百度了一大堆,都是千篇一 ...
- 清除input[type=number]的默认样式
input[type=number] { -moz-appearance:textfield; } input[type=number]::-webkit-inner-spin-button, inp ...
- LintCode主元素
主元素1: 这道题是编程之美上的一道原题,如果题目未对时间复杂度有严格要求的话可以先排序,再取中位数. 本题中要求算法达到时间复杂度为O(n),空间复杂度为O(1),算法如下: public int ...
- 消息队列的使用 RabbitMQ
RabbitMQ 是一款开源且比较流行的消息中间件.但用起来还是比较麻烦,有人封装了一层, 这就是 EasyNetQ . 一.安装 1.安装 Erlang: http://www.erlang.org ...
- Linux设备驱动框架设计
引子 Linux操作系统的一大优势就是支持数以万计的芯片设备,大大小小的芯片厂商工程师都在积极地向Linux kernel提交设备驱动代码.能让这个目标得以实现,这背后隐藏着一个看不见的技术优势:Li ...
- firemonkey ListView DynamicAppearance
Go Up to FireMonkey Application Design Contents [hide] 1 Customizing the List View Appearance Prope ...
- IPFS:世界正在悄然发生变化
世界正在悄然发生变化(IPFS) 2015-05-05 Juan Benet 在自己的终端里面敲入了下面的文字: > echo "hello worlds" | ipfs a ...