- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我每个月的第一个星期五晚上都有 cronjob我使用了下面提到的条目
00 20 1-7 * Fri [ "$(date '+\%a')" = "Fri" ] && $HOME/path/to/my/script.sh > /dev/null 2>&1
如果星期五在一个月的 1-7 日内,此条目应该运行我的脚本,但我的脚本甚至在 7 日之后(即在该月的所有星期五)执行。请建议如何修复它。
最佳答案
这是因为当您指定月中的某一天和星期几时,cron 将在这些约束中的任何一个为真时执行作业。来自 crontab (5) 的手册页:
Note: The day of a command's execution can be specified by two fields —
day of month, and day of week. If both fields are restricted (i.e.,
aren't *), the command will be run when either field matches the cur‐
rent time. For example,
``30 4 1,15 * 5'' would cause a command to be run at 4:30 am on the 1st
and 15th of each month, plus every Friday.
在 cron 中没有直接的方法来做你想做的事,但是 cron : how to schedule to run first Sunday of every month描述了使用 cron 运行脚本的解决方法,例如每个星期五,然后在脚本中计算日期是否在 1-7 范围内,只有在这种情况下才继续。
针对关于使用 5 而不是 Fri 来指定星期几的评论:使用 Fri 是可以的,如手册页所述:
Months or days of the week can be specified by name.
关于linux - 如何在每个月的第一个星期五运行 cronjob?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24217135/
我正在尝试执行不是很复杂的图像分析,以尝试找到不同的形状并计算它们的一些参数,如面积和周长(以像素为单位),我正在尝试在 Haskell 中执行此操作(我想这样做是为了尝试并使用函数式编程语言)。 第
查看 main 函数,我们可以看到我已将“星期一”硬编码到我的 setDay 公共(public)函数中。使用 c 字符串很容易从用户那里获取星期几(就像我在 setDay 中所做的那样),但是我如何
我正在寻找两个做两件事: 检查一周是否过去(基于星期几) 检查一天是否过去(基于日期) 我不确定解决这个问题的最佳方法是什么,因为比较两个 NSDates(一个在 2009 年 1 月 1 日 21:
伙计们,我想创建一个 13 日即将到来的 13 个星期五的列表我该怎么做? 我尝试了一年: public static void getFridayThirteen() { for (in
我想知道这个日期格式是什么 Friday, December 18th 也是这个标准日期格式,或者我必须努力工作才能得到这个。 谢谢。 最佳答案 我认为th 不可能通过格式化程序实现。虽然你可以这
我正在使用 UILocalNotification 进行报警。我有一个基于工作日(星期日、星期一、星期二、星期三、星期四、星期五、星期六)重复的自定义选项。这么多应用程序都做了这个过程。我尽力了。但我
下面的函数返回图表数据 上述函数返回的输出格式如下 [Object { date=Date, value=112, volume=1469}, Object { date=Date, value
我是一名优秀的程序员,十分优秀!