首页 > 系统服务 > 详细

linux计划任务之cron

时间:2019-09-19 01:37:32      阅读:550      评论:0      收藏:0      [点我收藏+]

cron计划任务之用户级

  • 1.安装crond
centos7 执行命令:

# yum install -y crontabs
/bin/systemctl restart crond.service #重启服务
/bin/systemctl status crond.service #查看crontab服务状态
  • 2.crond进程每分钟会处理一次计划任务 ,存储位置在 /var/spool/cron/
  • 3.管理方式
 crontab -l 列出当前用户的计划任务
 crontab -r 删除当前用户所有的计划任务
 crontab -e 编辑当前用户的计划任务

管理员可以使用 -u username,去管理其他用户的计划任务
示例

[root@Server-n93yom ~]# crontab -e //编辑一个计划任务* * * * * date >> /root/tmp/huhu.job   后面的命令可以替换为一个脚本/*.sh
[root@Server-n93yom ~]# crontab -l
* * * * * date >> /root/tmp/huhu.job
[root@Server-n93yom tmp]# tailf huhu.job
Wed Sep 18 23:30:01 CST 2019
[root@Server-n93yom tmp]# crontab -r
[root@Server-n93yom tmp]# crontab -l
no crontab for root
  • 4./etc/cron.deny 中定义的是禁止某用户去执行计划任务

  • 5.语法格式
第一列代表分钟(0-59)

第二列代表小时(0-23)

第三列代表天(1-31)

第四列代表月(1-12)

第五列代表周(0-6) 0表示周日

“*”代表所有的取值范围内的数字。如果直接用“*”则相当于“*/1”

“/”代表每的意思

“*/5″表示每5个单位

“-”代表从某个数字到某个数字

“,”分散的数字

 

# Example of job definition:

# .—————- minute (0 – 59)

# |  .————- hour (0 – 23)

# |  |  .———- day of month (1 – 31)

# |  |  |  .——- month (1 – 12) OR jan,feb,mar,apr …

# |  |  |  |  .—- day of week (0 – 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat

# |  |  |  |  |

# *  *  *  *  *  command to be executed

linux计划任务之cron

原文:https://www.cnblogs.com/guanbin-529/p/11546254.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!