crontab 任务计划 crond服务
crontab -u -e -l -r
5个*
格式:分,时,日,月,周 user command
/etc/crontab 配置文件html
crontab -e 编辑配置文件 crontab -l 查看任务计划 crontab -r 删除 crontab -u 指定用户
文件 /var/spool/cron/usermane 每一个用户的定时任务
格式范围是centos
分,0-59 时,0-23 日,1-31 月,1-12 周,1-6 (0、7表示周日)
可用格式1-5 表示一个范围
可用格式*/2
表示被2整除的数字,好比小时,那就是每隔2个小时
要保证服务是启动状态 systemctl start crond.servicebash
`0 3 * * * /bin/bash /root/sh/123.sh >>/tmp/123.log 2>>/tmp/321.log` 天天的3点00分 执行一个123.sh脚本,把正确结果放入123.log,错误结果放入321.log里
chkconfig 系统服务管理 Centos 7 还能兼容使用ssh
chkconfig - -list # 查看全部服务 chkconfig network off #开机关闭服务 on开机自启动 chkconfig - -level 2 off #2级别开机关闭
首先先放到/etc/init.d 目录下socket
chkconfig - -add #123 手动加入开机自启动 chkconfig - -del #123 手动删除
6以及以前的版本
chkconfig 使用的服务管理的机制是 SysV
7个运行级别 runlevelide
0 关机 1 单用户 2 和3级别只少了NFS服务 3 多用户级别 4 保留 5 图形界面 6 重启 reboot
centos 7 使用的服务管理机制是systemd 、target.net
systemd 系统管理服务rest
systemctl list-unit-files #查看全部的包括service、target、socket服务 systemctl list-unlis - -all - -type=service #只查看全部service服务 systemctl list-units - -type=service #只查看全部service服务但不包括未激活的任务 systemctl enable crond.service #开机自启动 systemctl disable crond.service #关闭自启动 systemctl status crond.service #查看指定服务状态 systemctl start crond.service #启动服务 systemctl stop crond,service #关闭服务 systemctl restart crond.service #重启服务 systemctl is-enable crond #检查服务是否开机自启动
ls /usr/lib/systemd/system 系统全部unit,分为如下类型code
service #系统服务 target #多个unit(service)组成的组 device #硬件设备 mount #文件系统挂载点 automount #自动挂载点 path #文件或路径 scope #不是由systemd启动的外部进程 slice #进程组 snapshot systemd #快照 socket #进程间通讯套接字 swapswap #文件 timer #定时器
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 systemctl is-enable crond.service #查看摸个服务是否为enable
系统为了方便管理用target来管理unit htm
systemctl list-unit-files - -type=target systemctl list-dependencies multi-user.target #查看指定target下面有哪些unit systemclt get-default #查看系统默认的target systemctl set-default multi-user.target
一个service属于一种类型的unit
多个unit组成了一个target
一个target里面包含了多个service
cat /usr/lib/systemd/system/sshd.service 看[install] 部分
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
anacron http://blog.csdn.net/strikers1982/article/details/4787226
xinetd服(默认机器没有安装这个服务,须要yum install xinetd安装) http://blog.sina.com.cn/s/blog_465bbe6b010000vi.html