免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1020 | 回复: 4
打印 上一主题 下一主题

[系统安装] crontab问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-12-06 15:00 |只看该作者 |倒序浏览
crontab 中,下面有什么区别

我想让我的脚本每小时执行一次命令

* */2 * * * 我这样设置后,每分钟执行一次命令?

0 */2 * * *
* */2 * * *

有知道的请告知下,谢谢

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
2 [报告]
发表于 2012-12-06 16:12 |只看该作者
* */2 * * *这个是每2小时执行一次,* */1 * * *才是1小时

论坛徽章:
0
3 [报告]
发表于 2012-12-06 16:13 |只看该作者
鸟哥私房菜里面有讲这个的,你看看。

论坛徽章:
0
4 [报告]
发表于 2012-12-06 16:35 |只看该作者
测试结果

0 */1 * * *  每小时执行一次
* */1 * * *  每分钟执行一次

论坛徽章:
0
5 [报告]
发表于 2012-12-06 17:16 |只看该作者
gzhgyzhh 发表于 2012-12-06 16:35
测试结果

0 */1 * * *  每小时执行一次
  1. SHELL=/bin/bash
  2. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  3. MAILTO=root
  4. HOME=/

  5. # For details see man 4 crontabs

  6. # Example of job definition:
  7. # .---------------- minute (0 - 59)
  8. # |  .------------- hour (0 - 23)
  9. # |  |  .---------- day of month (1 - 31)
  10. # |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
  11. # |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
  12. # |  |  |  |  |
  13. # *  *  *  *  * user-name command to be executed
复制代码
我也试了一下,事实证明前面的时间一定要填上数值。如果都为*,即使你在月的位置*/1它也是每分钟执行一次。

Commands are executed by cron( when the
       minute, hour, and month of year fields match the current time, and at least one  of  the  two
       day  fields  (day  of month, or day of week) match the current time (see "Note" below).  Note
       that this means that non-existent times, such as "missing hours" during daylight savings con-
       version,  will  never match, causing jobs scheduled during the "missing times" not to be run.
       Similarly, times that occur more than once (again, during daylight savings  conversion)  will
       cause matching jobs to be run twice.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP