八周一次课(3月26日) 10.23 linux任务计划cron 10.24 chkconfig工具 10.25 systemd管理服务 10.26 unit介绍 10.27 target介绍 扩展

  1. anacron http://blog.csdn.net/strikers1982/article/details/4787226
  2. xinetd服(默认机器没有安装这个服务,需要yum install xinetd安装) http://blog.sina.com.cn/s/blog_465bbe6b010000vi.html
  3. systemd自定义启动脚本 http://www.jb51.net/article/100457.htm linux任务计划cron 我们在此处查看一下 crontab 脚本的格式为 0 3 * * * /bin/bash /usr/local/bin/123.sh >>/tmp/123.log 2>>/tmp/123.log 此处的意思为每天凌晨三点把去执行 下面这个命令 bin/bash 加上脚本名字 输出到123.log里 2后面表示错误的也记录进该文件>直接添加 >>追加重定向 0 3 时间1 -10(一到十月) */2(被2整除的月份) 2,5(指定星期) systemctl start crond.service (启动服务才能生效) 检查服务是否生效 ps aux |grep crond systemctl status crond 也可以查看命令状态 systemctl stop crond 关闭命令,systemctl status crond查看命令状态 有时候写任务计划没有执行 有可能是因为脚本里面使用的命令 没有使用绝对路径,或者是把命令加入到PATH里面去 crontab -l 查看当前任务 ls /var/spool/cron/root 任务目录 可以把任务目录直接备份, -u指定用户 chkconfig工具 chkconfig --list列出当前的服务 此处可以看出7之前都是用sysv的管理模式,7用的是systemd服务 chkconfig 只能看到两个了 在 init.d里面可以看到别的服务 此处的 0 - 6分别表示的是 0.是关机状态 1.是单用户模式 2.比3少了nfs(一种网络服务)服务 3.是多用户模式,不带图形 4.是保留状态5.是多用户带图形模式 6.重启 chkconfig --level 35 network off 关闭网络35服务 add 可以添加服务 chkconfig --add 123 添加的条件是只有服务存在于init.d目录下的时候才能添加到服务列表里面去 del是删除 systemd管理服务 在centos7里面之后是使用的systemd服务 首先根据系统的提示要使用systemctl list-units -files查看服务 太复杂 systemctl list-units --all --type=service此处会查看service的比较详细 unit介绍 什么是unit unit的相关命令 target介绍 systemctl list-unit-files --type=target查看系统的target systemctl list-dependencies multi-user.target //查看指定target下面有哪些unit