java crontable 解析_CRON 定时任务 在线解析

简介

Linux中的定时任务用到的最多的,也是默认的程序就是CRON

ps aux | grep cron

systemctl status crond.service

CRON定时任务的最小单位是分钟,也就是最小只能1分钟执行1次,更小的定时任务可以用shell循环配合sleep命令来实现,如果不用定时任务提供的6位表达式工具来实现定时任务的服务,强行使用shell循环来实现,将会非常繁琐,比如要实现每个月1号执行1次的任务

另外一个比较流行的定时任务工具是Java语言用到的Quartz,这个使精确到秒级的

常用帮助

man cron

man crontab

info cron

info crontab

简单实操

[root@node1 ~]# crontab -e

[root@node1 ~]# crontab -l

# 注释信息

* * * * * date "+\%F \%T" &>> /tmp/cron-test.txt && df -h | fgrep "/home" &>> /tmp/cron-test.txt

[root@node1 ~]# tailf /var/log/cron

Feb 28 15:27:47 node1 crontab[4505]: (root) BEGIN EDIT (root)

Feb 28 15:27:52 node1 crontab[4505]: (root) REPLACE (root)

Feb 28 15:27:52 node1 crontab[4505]: (root) END EDIT (root)

Feb 28 15:28:01 node1 crond[2942]: (root) RELOAD (/var/spool/cron/root)

Feb 28 15:28:01 node1 CROND[4508]: (root) CMD (date "+%F %T" &>> /tmp/cron-test.txt && df -h | fgrep "/home" &>> /tmp/cron-test.txt)

Feb 28 15:29:01 node1 CROND[4536]: (root) CMD (date "+%F %T" &>> /tmp/cron-test.txt && df -h | fgrep "/home" &>> /tmp/cron-test.txt)

Feb 28 15:30:01 node1 CROND[4543]: (root) CMD (date "+%F %T" &>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值