高端的废话就是没有引言这种废话。
1.这里我已我的centos7为例输入:
systemctl list-unit-files #查看开机启动表如图下:

最左边就是服务 ,最右边就是状态 。如当你想要服务器开机启动firewalld(防火墙)输入
systemctl enable firewalld
具体systemctl使用直接看使用说明:
Query or send control commands to the systemd manager.-h --help Show this help--version Show package version--system Connect to system manager-H --host=[USER@]HOSTOperate on remote host-M --machine=CONTAINEROperate on local container-t --type=TYPE List units of a particular type--state=STATE List units with particular LOAD or SUB or ACTIVE state-p --property=NAME Show only properties by this name-a --all Show all loaded units/properties, including dead/emptyones. To list all units installed on the system, usethe 'list-unit-files' command instead.-l --full Don't ellipsize unit names on output-r --recursive Show unit list of host and local containers--reverse Show reverse dependencies with 'list-dependencies'--job-mode=MODE Specify how to deal with already queued jobs, whenqueueing a new job--show-types When showing sockets, explicitly show their type-i --ignore-inhibitorsWhen shutting down or sleeping, ignore inhibitors--kill-who=WHO Who to send signal to-s --signal=SIGNAL Which signal to send--now Start or stop unit in addition to enabling or disabling it-q --quiet Suppress output--no-block Do not wait until operation finished--no-wall Don't send wall message before halt/power-off/reboot--no-reload Don't reload daemon after en-/dis-abling unit files--no-legend Do not print a legend (column headers and hints)--no-pager Do not pipe output into a pager--no-ask-passwordDo not ask for system passwords--global Enable/disable unit files globally--runtime Enable unit files only temporarily until next reboot-f --force When enabling unit files, override existing symlinksWhen shutting down, execute action immediately--preset-mode= Apply only enable, only disable, or all presets--root=PATH Enable unit files in the specified root directory-n --lines=INTEGER Number of journal entries to show-o --output=STRING Change journal output mode (short, short-iso,short-precise, short-monotonic, verbose,export, json, json-pretty, json-sse, cat)--plain Print unit dependencies as a list instead of a tree向系统管理器查询或发送控制命令。
-h--help显示此帮助
--version显示包版本
--系统连接到系统管理器
-H--主机=[用户@]主机
在远程主机上操作
-M--机器=集装箱
在本地容器上操作
-t-type=type列出特定类型的单位
--state=state列出具有特定LOAD或SUB或ACTIVE状态的单元
-p--property=NAME仅显示此名称的属性
-a--all显示所有加载的单元/属性,包括死/空
一个。要列出系统上安装的所有单元,请使用
而是使用“list unit files”命令。
-l—full输出时不省略单元名称
-r--recursive显示主机和本地容器的单元列表
--reverse使用“列表依赖项”显示反向依赖项
--作业模式=模式指定如何处理已排队的作业
排队等待新作业
--show types显示套接字时,显式显示其类型
-i——忽略抑制剂
关机或睡觉时,忽略抑制剂
--杀死谁=向谁发送信号的世界卫生组织
-s--signal=signal发送哪个信号
--现在除了启用或禁用装置外,还可以启动或停止装置
-q—安静抑制输出
--no block不要等到操作完成
--没有墙在停止/断电/重新启动之前不发送墙消息
--no reload在启用/禁用单元文件后不重新加载后台进程
--无图例不打印图例(列标题和提示)
--无寻呼机不将输出管道传输到寻呼机
--无询问密码
不询问系统密码
--全局启用/禁用全局单位文件
--runtime仅临时启用单元文件,直到下次重新启动
-f--force启用单元文件时,覆盖现有符号链接
关闭时,立即执行操作
--预设模式=仅应用启用、仅禁用或所有预设
--root=PATH启用指定根目录中的单元文件
-n--lines=整数要显示的日记账分录数
-o--output=STRING更改日志输出模式(短、短iso、,
简短精确,简短单调,冗长,
导出、json、json漂亮、json sse、cat)
--纯打印单元依赖项作为列表而不是树
最主要还是需要知道systemctl中几个简单使用命令:
#启动服务项
systemctl start <你要开启的服务器项> #开启哪一项#所以就需要设置开机启动
systemctl enable <你要开启的服务器项> #移除开机启动项
systemctl disable <你要开启的服务器项> #结束服务项
systemctl stop <你要开启的服务器项> #重启服务项
systemctl restart <你要开启的服务器项>
回顾正题来当我们想查看具体开机启动项时:
systemctl list-unit-files | grep enabled #grep 可以理解为是一个查找命令
当想启动其他脚本时,这里以demo.sh脚本(脚本在/home/xiaojie文件中)为例:
1、要将脚本移动到/etc/rc.d/init.d目录下 mv /home/xiaojie/demo.sh /etc/rc.d/init.d
2、增加脚本的可执行权限 chmod +x /etc/rc.d/init.d/demo.sh
3、添加脚本到开机自动启动项目中 cd /etc/rc.d/init.d chkconfig --add demo.sh chkconfig demo.sh on


















