如何在特定时间段内激活cron命令一次? [英] How do i activate cron command once within specific time frame?
问题描述
我的系统的基本信息:我有一个音乐系统,人们可以安排歌曲在特定时间开始和结束。
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(开始时间使用play etc等命令),另一个设置为3.20(结束时间使用命令end etc)。
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屋!