crontab -e 配置定时任务

crontab -e 配置定时任务Editthisfile Eachtasktoru indicatingwi andwhatcomma

时间格式

在这里插入图片描述

crontab -e 具体配置

# Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command # 分钟 小时 某天 某月 星期几 命令 0 23 * * * /root/scripts/login_day.sh 0 23 * * 7 /root/scripts/login_week.sh 0 0 1 * * /root/scripts/login_month.sh # total used time(hours) of every province for everyday 0 23 * * * /root/scripts/day_total_used_time.sh 

examples

Every Minute * * * * * Every Five Minutes */5 * * * * Every 10 Minutes */10 * * * * Every 15 Minutes */15 * * * * Every 30 Minutes */30 * * * * Every Hour 0 * * * * Every Two Hours 0 */2 * * * Every Six Hours 0 */6 * * * Every 12 Hours 0 */12 * * * During the Work Day */5 9-17 * * * Every day at Midnight 0 0 * * * Every Two Weeks 0 0 * * Sun [ $(expr $(date +%W) % 2) -eq 1 ] && /path/to/command At the Start of Every Month 0 0 1 * * On January 1st at Midnight 0 0 1 1 * 

References

  1. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07
  2. https://crontab.guru/examples.html
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/229306.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月16日 下午5:00
下一篇 2026年3月16日 下午5:00


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号