如何在特定时间范围内激活一次 cron 命令? [英] How do i activate cron command once within specific time frame?

查看:44
本文介绍了如何在特定时间范围内激活一次 cron 命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于我的系统的基本信息:我有一个音乐系统,人们可以在其中安排歌曲在特定时间开始和结束.

Basic information about my system: I have a music system where people can schedule songs to start and end at a specific time.

操作系统:Arch linux

OS: Arch linux

它目前设置了两个 cron.一个可以说在 1.50(开始时间使用播放等"命令),另一个设置在 3.20(结束时间使用结束等"命令).

It sets two crons at the moment. One lets say at 1.50 (start time with a command like "play etc") and another set at 3.20 (end time with a command like "end etc").

我的设置运行良好,我可以结束删除计划等,但我现在注意到一个问题!如果我设置了上述时间并关闭系统(我的系统是树莓派)并在假设 2.00 时重新打开并且我错过了 1.50 的截止日期,则音乐不会开始(显然)并且我想尝试让它如此不不管我什么时候在一个范围内打开它,可以说:1.50 - 3.20 它将启动播放命令.但是它会运行一次命令!

My setup works perfectly and i can end delete schedules etc etc but i now noticed an issue! If i set the above times and turn the system off (My system is a raspberry pi) and turn back on at lets say 2.00 and i missed the 1.50 deadline, the music doesnt start (obviously) and i want to try make it so no matter what time i turn it on within a range lets say: 1.50 - 3.20 it will start the play command. But it will run the command once!

我环顾四周,得到的命令如下:

I looked around and the commands i got was like:

0 1.50-3.20/2 * * * your_command.sh

但那是每 2 小时运行一次.我希望它在这些时间之间只运行一次?谢谢!

But thats to run every 2 hours. I want it to run once only between these times? Thanks!

推荐答案

我通过创建一个 PHP 文件并在重新启动时加载页面然后执行其工作并重定向回某某来解决该问题.

I solved the issue by creating a PHP file and load the page on reboot then do its work and redirect back to such and such.

这篇关于如何在特定时间范围内激活一次 cron 命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆