简体   繁体   English

cron / wget-每5小时30分钟运行一次页面

[英]cron/wget - Run page every 5 hours and 30 minutes

I need help with 2 things. 我需要2件事的帮助。 I'm creating a PHP page that restarts a game server every 6 hours through sending an RCON command (#restart) and I would like to have that page auto-refresh (Change case eg http://mydomain.com/restart.php?cmd=#say&timeleft=30 and send another RCON Command to the server (#say) that says "Server restart in 30 minutes" at first, then the second time it says "Server restart in 10 minutes" and so on for 5 minutes and 1 minute. And when that time has passed (Approx 30 minutes), I want the page to send the restart command. I'm guessing that I need to set a cron job that runs the page with a 5 hour and 30 minute interval. 我正在创建一个PHP页面,该页面通过发送RCON命令(#restart)每6小时重新启动游戏服务器,并且我希望该页面自动刷新(更改大小写,例如http://mydomain.com/restart.php ?cmd =#say&timeleft = 30并首先向服务器(#say)发送另一个RCON命令,该命令显示“服务器在30分钟内重新启动”,然后第二次显示“服务器在10分钟内重新启动”,依此类推,持续5分钟然后是1分钟,而当该时间过去了(大约30分钟)时,我希望页面发送重新启动命令。我猜我需要设置一个cron作业,以5小时30分钟的间隔运行该页面。

I have the PHP section done (RCON library and the commands aswell as cases (eg http://mydomain.com/restart.php?cmd=#say&timeleft=30 )) I have yet to figure out how to do this in PHP, or do I need to do it in jQuery or AJAX or something? 我已经完成了PHP部分(RCON库和命​​令以及案例(例如, http: //mydomain.com/restart.php?cmd=#say&timeleft=30)),但我还没有弄清楚如何在PHP中做到这一点,还是我需要用jQuery或AJAX或其他工具来做? Thanks in advance! 提前致谢! Regards, Tom. 谢谢,汤姆。

What you need to do is post a command that specifies the time for restart.. When you visit the page it should check if a restart is imminent, then display restart time - current time. 您需要做的是发布一个指定重新启动时间的命令。当您访问该页面时,它应检查是否即将重新启动,然后显示重新启动时间-当前时间。

You can then just cron job the restart every 6 hours: 然后,您可以每6小时执行一次cron作业,以重新启动:

* */6 * * * wget http://mydomain.com/restart.php * * / 6 * * * wget http://mydomain.com/restart.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM