linux - 多次使用 *AND* 的 Cron 模式

标签 linux cron

我想为表达式每天晚上 7 点、晚上 8:30 和晚上 9:45 创建一个 cron 模式

是否可以为其创建一个 cron 模式,或者我将不得不编写 3 个单独的模式?

最佳答案

单独使用 cron,您将不得不创建 3 个独立的 cron 作业。但是,这里有一个可能的解决方法:您可以为晚上 7 点创建一个 cron 条目,例如:

0 19 * * * /folder/script

然后创建一个脚本,在晚上 8:30 和 9:45 调用其他命令之前“休眠”您需要的时间,例如:

#!/bin/bash
nohup my_command_here &
#sleep until 8:30 PM - 90 minutes or 5400 seconds
sleep 5400
nohup my_command_2_here &
#sleep until 9:45 PM - 75 minutes or 4500 seconds
sleep 4500
nohup my_command_3_here &
exit

关于linux - 多次使用 *AND* 的 Cron 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41457413/

相关文章:

python - 给文件添加时间戳,python subprocess linux

php - 同时运行多个 cron 作业时如何克服服务器负载问题?

amazon-web-services - AWS Glue - CRON 计划触发器

linux - Crontab 不记录到文件

linux - 如何验证我的 cron 作业将在 AWS 上使用 Ubuntu 运行?

linux - 从无线设备驱动程序获取比特率的值。

php/apache2 - if (bug - discussion, finding an explanation) 简写

正则表达式匹配两个字符串之间所有字符的最后一次出现

linux - Apache服务器权限错误

php - cron 文件以在每次运行后按顺序更新数据库