gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 12:36:55 25 4
gpt4 key购买 nike

我想为表达式每天晚上 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com