SYSTEMD

简介:

八周一次课(9月18日)

10.23 linux任务计划cron

10.24 chkconfig工具

10.25 systemd管理服务

10.26 unit介绍

10.27 target介绍


10.23 linux任务计划cron

wKiom1m_2DrxuzTvAAN9YU5XpZk079.png

配置文件位置/etc/crontab

 * * * * *  /bin/bash /tmp/1 > > /tmp/1 2>>/tmp/2 每分钟执行

0 3 1-10 */2 *  没两个月的1-10号的三点执行。

 systemctl start crond  启动服务。

注意:在写脚本的时候需要加上绝对路径。

[root@111 ~]# cat /var/spool/cron/root 

 * * * * *  echo "123" >/tmp/1

 计划任务存储的地方


10.24 chkconfig工具

cent7用systemd

wKiom1m_2EzTKDFGAARWuanS8DE491.png

chkconfig管理的脚本的路径

chkconfig network off 关闭服务

系统分了七个级别 每个级别只有特定的服务是开启的。

chkconfig --list查看

[root@111 ~]# chkconfig --list


Note: This output shows SysV services only and does not include native

      systemd services. SysV configuration data might be overridden by native

      systemd configuration.


      If you want to list systemd services use 'systemctl list-unit-files'.

      To see services enabled on particular target use

      'systemctl list-dependencies [target]'.


iprdump         0:off 1:off 2:on 3:on 4:on 5:on 6:off

iprinit         0:off 1:off 2:on 3:on 4:on 5:on 6:off

iprupdate       0:off 1:off 2:on 3:on 4:on 5:on 6:off

netconsole      0:off 1:off 2:off 3:off 4:off 5:off 6:off

wKiom1m_2FnAN_2OAABJKS9xlik052.png

可以指定特定级别的服务关闭或者开启

自定义启动服务

第一步在/etc/init.d/ 下面建立自己的服务脚本

第二部 chkconfig --add 123

chkconfig --list

就可以实现开机自启服务

10.25 systemd管理服务

cent7的服务管理工具

wKiom1m_2G_wllxXAAXUdgx_UmM993.png

wKiom1m_2HnBAft2AARO2dONpKU687.png

列出所有的服务。

 systemctl enable  开机启动。

 systemctl is-enabled  XX查看某个服务是否开机自启

enable就会创建一个软连接。

10.26 unit介绍

wKioL1m_2FnSoHGNAAAVlsHyggQ970.png

wKiom1m_2Jvyux9eAAg4LMrdb2k535.png

wKioL1m_2GvC9uwwAAAp_HzytSM009.png

systemctl list-units --all列出所有的units

10.27 target介绍

wKiom1m_2NPC4eRHAASdIIvv0cU320.png

[root@111 system]# systemctl get-default 

graphical.target 查看默认的target 

[root@111 system]# systemctl set-default multi-user.target 

rm '/etc/systemd/system/default.target'

ln -s '/usr/lib/systemd/system/multi-user.target' '/etc/systemd/system/default.target'

开机就是命令行模式之前是图形界面模式。

本文转自 zfno11 51CTO博客,原文链接:

http://blog.51cto.com/zfno111/1966488


相关文章
|
4月前
|
监控 Linux 开发者
Docker服务systemd配置文件详解
Docker服务systemd配置文件详解
111 0
|
关系型数据库 Linux Apache
|
5月前
|
NoSQL
systemd-coredump
systemd-coredump
|
11月前
|
监控 Java 数据库连接
服务--systemd的管理
服务--systemd的管理
115 0
|
Linux
Linux:systemctl、service、chkconfig
Linux:systemctl、service、chkconfig
103 0
|
运维 网络协议 关系型数据库
Systemd | 学习笔记
快速学习Systemd,掌握如何进行服务的管理和配置,并引导学生主动完成服务的编写,为后续的运维工作打下基础
Systemd | 学习笔记
systemd简介
systemd是Linux的一个工具,是CentOS7.x系统启动的第一个进程 1.systemd的一些相关命令 (1)systemctl 系统管理 #检查系统是否充分的运行 [root@localhost ~]# systemctl is-system-running r...
1400 0