操作

在/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系统增加开机启动服务/应用的更多相关文章

  1. Linux系统入门---开机启动流程

    目录 Linux系统入门---开机启动流程 一.centos6 二.systemd管理进程 1.查看级别 三.centos7实践案例: 1.案例1:centos7系统,单用户修改root密码 案例2: ...

  2. Linux系统的开机启动顺序

    Linux系统的开机启动顺序加载BIOS–>读取MBR–>Boot Loader–>加载内核–>用户层init一句inittab文件来设定系统运行的等级(一般3或者5,3是多用 ...

  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 ...

  4. linux chkconfig添加开机启动服务

    --add:增加所指定的系统服务,让chkconfig指令得以管理它,并同时在系统启动的叙述文件内增加相关数据: --del:删除所指定的系统服务,不再由chkconfig指令管理,并同时在系统启动的 ...

  5. NO19 优化Linux系统--重要开机自启动服务--关闭自启动项

    **如何优化Linux系统: 1   不用root,添加普通用户,通过sudo授权管理.2   更改默认的远程连接SSH服务端口及禁止root用户远程连接.3   定时自动更新服务器时间.4   配置 ...

  6. 基于Linux Shell的开机启动服务

    CentOS重启后,很多服务需要手动启动,很是麻烦,今天把需要开机启动或关闭的服务整理了一下,放入Linux Shell中,再将该Shell加入/etc/rc.local中,即可实现存储的自动挂载.S ...

  7. linux系统下开机启动流程

    在了解开机启动流程之前,还是得先了解一些磁盘的基本知识.磁盘主要由盘片,机械手臂,磁头,主轴马达构成.盘片就是存储数据的物理单位了.然后盘片上我们可以分成扇区(sector)和柱面(cylinder) ...

  8. linux自定义开机启动服务和chkconfig使用方法

    linux自定义开机启动服务和chkconfig使用方法 1. 服务概述在linux操作系统下,经常需要创建一些服务,这些服务被做成shell脚本,这些服务需要在系统启动的时候自动启动,关闭的时候自动 ...

  9. (转)linux自定义开机启动服务和chkconfig使用方法

    原文:https://www.cnblogs.com/jimeper/archive/2013/03/12/2955687.html linux自定义开机启动服务和chkconfig使用方法 1. 服 ...

随机推荐

  1. 【Webpack的使用指南 02】Webpack的常用解决方案

    说是解决方案实际上更像是webpack的插件索引. 写这一篇的目的是为了形成一个所以,将来要用时直接来查找即可. 索引目录 1.自动构建HTML,可压缩空格,可给引用的js加版本号或随机数:html- ...

  2. 去中心化类微博应用 mastodon

    一句话重点,去中心,没监管,自己对自己信息做主,没人随便删你消息的分布式社交应用 mastodon. 建了一个实例, https://cncs.io 来专门讨论计算机相关信息,欢迎大家注册来玩.已有用 ...

  3. 基于Avocado 的 QData MySQL自动化测试.md

    qdata-mysql 自动化测试概要设计 │   ├── 1. 依赖环境 │   │   ├ │   │   └───── │   ├── 2. 配置文件 │   │   ├ │   │   └── ...

  4. A Proof of Stake Design Philosophy - PoS权益证明设计理念

    之前在EthFans上看到了关于PoS(权益证明)的相关文章(原文链接),本着学习的态度,对这篇文章进行了翻译.第一次翻译关于区块链的文章,有些单词及句子的措辞还不是很准确,如果发现有翻译的不恰当的地 ...

  5. PHP方法实现1-9数列中添加‘+’,‘-’或'',使和为100,并输出数列

    今天收到个题目:编写一个在1,2,3,4,5,6,7,8,9(顺序不能变)数字之间插入 + 或- 或什么都不插入,使得计算结果总是100的程序,并输出所有的可能性.例如 1+2+34-5+67-8+9 ...

  6. canvas画布,时钟

    原理代码如下: <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...

  7. vue中$on与$emit的实际应用

    $on常用于监听自定义事件,触发后可传入参数 //监听event1事件 vm.$on('event1',function(msg){ console.log(msg) }) //触发event1自定义 ...

  8. sublime安装、注册、插件

    1. sublime下载:http://www.sublimetext.com/3 2. 输入注册码: help->Enter License —– BEGIN LICENSE —– Antho ...

  9. 数据系统的未来------《Designing Data-Intensive Applications》读书笔记17

    终于来到这本书最后的一章了<Designing Data-Intensive Applications>大部头,这本书应该是我近两年读过最棒的技术书籍.作者Martin Kleppmann ...

  10. zabbix自定义key监控memcache状态及其他服务进程

    一.在客户端 1.到/usr/loca/zabbix/conf/zabbix_agentd.conf里添加         UserParameter=memcached_stats[*],(echo ...