Linux-Crontab定时任务
来源:互联网 发布:java 替换@为换行 编辑:程序博客网 时间:2024/06/05 13:03
1.介绍
crond是linux下用来周期性的执行某种任务或等待处理某些事件的一个守护进程,与windows下的计划任务类似,当安装完成操作系统后,默认会安装此服务工具,并且会自动启动crond进程,crond进程每分钟会定期检查是否有要执行的任务,如果有要执行的任务,则自动执行该任务。
Linux下的任务调度分为两类,系统任务调度和用户任务调度
2.指令
crontab
yum安装
yum -y install crontab
crond的几个文件介绍:
/etc/crontab文件包括下面几行:[root@localhost ~]# cat /etc/crontab SHELL=/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/binMAILTO=""HOME=/# run-parts51 * * * * root run-parts /etc/cron.hourly24 7 * * * root run-parts /etc/cron.daily22 4 * * 0 root run-parts /etc/cron.weekly42 4 1 * * root run-parts /etc/cron.monthly使用者权限文件:文件:/etc/cron.deny说明:该文件中所列用户不允许使用crontab命令文件:/etc/cron.allow说明:该文件中所列用户允许使用crontab命令文件:/var/spool/cron/说明:所有用户crontab文件存放的目录,以用户名命名
使用 命令 有点类似 Spring的Scedule
首先 编辑文件 比如hrcrond
编辑: * * * * * echo “hello” 每隔一分钟执行 一次
运行前首先 看下crond 服务有没有起来 :
service crond startservice crond stopservice crond restartservice crond statusservice crond reload //重新载入配置查看crontab服务是否已设置为开机启动,执行命令:ntsysv加入开机自动启动:chkconfig –level 35 crond on
执行 :crontab 文件编辑:crontab -e //不用重启 修改生效 编辑器需要配置环境变量查看:crontab -l删除:crontab -r //删除的是 /var/spool/cron/下面的 以用户名命名的文件
日志查看:
tail -f /var/log/mail/cron
commod脚本执行发送的mail右键 通过/etc/crontab 配置发送
阅读全文
0 0
- Linux Crontab 定时任务
- Linux 定时任务 crontab
- Linux 定时任务 crontab
- Linux Crontab 定时任务
- Linux Crontab 定时任务
- linux 定时任务crontab
- linux 定时任务crontab
- linux定时任务 crontab
- linux 定时任务 crontab
- Linux - crontab(定时任务)
- linux crontab定时任务
- linux----crontab----定时任务
- Crontab Linux 定时任务
- linux定时任务--crontab
- linux定时任务crontab
- Linux定时任务crontab
- Linux定时任务crontab
- linux crontab 定时任务
- Manifest
- html5 localStorage api
- ubuntu系统下一些问题的解决1
- java list 转 tree,加排序
- Navicat premium连接Oracle报ORA-12545错误
- Linux-Crontab定时任务
- 正则笔记积累
- canvas系列教程02-直线和曲线
- 2017年12月21日
- java线程安全和锁机制详解
- Navicat premium连接Oracle报ORA-12541错误
- Java虚拟机工作原理
- vue.js移动端配置flexible.js
- while和if的区别