7月17号

10.23 linux任务计划cron

ron任务计划功能的操作都是通过crontab这个命令来完成的。其中常用的选项有:

-u :指定某个用户,不加-u选项则为当前用户;

-e :制定计划任务;

-l :列出计划任务;

-r :删除计划任务。

crontab  -e

从左到右,依次为:分,时,日,月,周,命令行。而上面的例子的含义是:在6月5日(这一天必须是星期3)的10点01分执行命令 echo "ok" >>/xiang/test1.log 2>>/xiang/test2.log

crontab -r 删除日志

查看已经设定的任务计划使用 crontab  -l

10.24 chkconfig工具

CentOS 6上的服务管理工具,Linux系统所有的预设服务可以查看/etc/init.d/目录得到

命令:ls /etc/init.d/ 可以查看系统预设服务

系统预设服务都是可以通过这样的命令实现 service  服务名  start|stop|restart 这里的服务名就是/etc/init.d/目录下的这些文件了。除了可以使用 service  crond start 启动crond外,还可以使用 /etc/init.d/crond start 来启动。

命令:chkconfig --list列出所有的服务以及每个级别是否开启:

这里的级别(0,1,2,3,4,5,6)就是 /etc/inittab 里面的那几个启动级别了,0、1、6运行级别被系统保留:其中0作为shutdown动作,1作为重启至单用户模式,6为重启;在一般的Linux系统实现中,都使用了2、3、4、5几个级别,在CentOS系统中,2表示无NFS支持的多用户模式,3表示完全多用户模式(也是最常用的级别),4保留给用户自定义,5表示图形登录方式

chkconfig --add xpf添加服务(不成功)

原因如下图

要添加服务之前要保证/etc/init.b/目录下有xpf文件 且该文件要有一定格式要是shell脚本?

chkconfig --del xpf 删除

用 --level 指定级别,后面是服务名,然后是off或者on,`--level 后还可以跟多个级别:chkconfig --level 345 xpf off  3,4,5显示为off

另外还可以省略级别,默认是针对2,3,4,5级别操作:chkconfig xpf on

10.25 systemd管理服务

ls /usr/lib/systemd/system //系统所有unit,分为以下类型

 service 系统服务

 target 多个unit组成的组

 device 硬件设备

 mount 文件系统挂载点

 automount 自动挂载点

 path 文件或路径

 scope 不是由systemd启动的外部进程

 slice 进程组

 snapshot systemd快照

 socket 进程间通信套接字

 swap  swap文件

 timer 定时器

systemctl list-units --all --type=service列出系统所有服务

systemctl enable crond .service //让服务开机启动

systemctl disable crond //取消开机启动

systemctl status crond

systemctl stop crond //停止服务

systemctl start crond //启动服务

systemctl restart crond //重启服务

systemctl is-enabled crond //检查服务是否开机启动

10.26 unit介绍

unit相关的命令

 systemctl list-units //列出正在运行的unit

 systemctl list-units --all //列出所有,包括失败的或者inactive的

 systemctl list-units --all --state=inactive //列出inactive的unit

 systemctl list-units --type=service//列出状态为active的service

 systemctl is-active crond.service //查看某个服务是否为active

10.27 target介绍

系统为了方便管理用target来管理unit

 systemctl list-unit-files --type=target;查看当前系统所有的target

systemctl list-dependencies multi-user.target //查看指定target下面有哪些unit

 systemctl get-default //查看系统默认的target

 systemctl set-default multi-user.target

 一个service属于一种类型的unit

 多个unit组成了一个target

 一个target里面包含了多个service

 cat /usr/lib/systemd/system/sshd.service //看[install]部分

转载于:https://my.oschina.net/u/3869214/blog/1858481

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值