10.23 linux任务计划cron
任务计划在linux下是必不可少的,它可能是一个脚本,也可能是一个命令,不管那种形式都得有一个时间去执行它
crontab配置文件下面的5个*位置的解释
crontab -e定义文件,用法是跟vi编辑文件一样的
0晨3点去执行这个命令的脚本
1-10号的3点执行这个脚本
双月的1-10号执行这个脚本
双月的周二和周五才执行这个脚本
重启服务后,查看是否有这个服务
查看服务的状态是绿色,显示runing正明这个服务正常启动
如果任务没有执行很有可能是命令没有用绝对路径,因为用的命令不在变量PATH里,所以要么使用绝对路径,要么将命令加入到PATH变量里
每一个执行的脚本最好都写上追加正确与错误的内容到指定的文件,这样就可以有迹可寻,当有错误时可以查看下错误的文件日志就知道了
备份脚本的内容,可以把下面的root直接拷贝就行了,如果是user用户就会是user名称的文件
crontab -r是删除脚 本
10.24 chkconfig工具
这个工具在centos7里面已经作为过渡版本了,只剩下这2个服务了
0-6级别的状态
0表示关机
1表示 单用户模式
2 表示多用用户模式,只不过比3少了nfs服务 ,nfs是一种网络文件系统
3表示多用户模式,只不过不带图形
4表示保留的状态 ,暂时没用
5表示多用户模式,而且是带图形
6级别是重启
这2个服务脚本的位置在这个目录下
把network开启的服务状态更改为关闭的状态
把network关闭的服务状态更改为开启的状态
加入服务到列表里,首先要把123放到 /etc/init.d/目录下
再添加这个123这个服务脚本到列表下
启动123文件是有要求的,首先它是一个脚本
删除一个服务
10.25 systemd管理服务
10.26 unit介绍
unit相关的命令
10.27 target介绍
扩展
- anacron http://blog.csdn.net/strikers1982/article/details/4787226
- xinetd服(默认机器没有安装这个服务,需要yum install xinetd安装) http://blog.sina.com.cn/s/blog_465bbe6b010000vi.html
- systemd自定义启动脚本 http://www.jb51.net/article/100457.htm
转载于:https://blog.51cto.com/13450039/2066578