安排活动的最佳方式
除了 cron 之外,还有其他选项可以安排 php 备份脚本在特定时间运行吗?我知道你可以使用 php 本身来安排事情,但只有当网站获得流量时它才会触发。 还有其他选择吗? 谢谢 :-)
is there any other option other than cron to schedule the running of a php backup script at a certain time?. I know you can use php itself to schedule things, but it will only fire if the site is getting traffic.
Are there any other options ?.
Thanks :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您正在谈论数据库备份,则 MySQL 5.1 及更高版本具有 CREATE EVENT 可用于定期或设定时间触发事件(例如可以将表结构/数据转储到文件的存储过程)
If you're talking about a database backup, then MySQL 5.1 and above has CREATE EVENT which can be used to trigger events (such as stored procedures that can dump table structure/data to file) at regular intervals or set times
嗯,cron jobs 是一个解决方案。但大多数情况下没有必要。
如果您的脚本在站点外执行某些操作(例如发送电子邮件或其他操作),那么它一定是一个 cron 作业。
但是......
我曾经制作过一个基于文本的角色扮演游戏,其中几个动作存储在数据库中等待在指定时间触发。我发现,如果脚本在应该的时间触发,或者当第一个人在时间超出时间戳后访问页面时,这没有任何区别。您可以在显示页面内容之前执行这些事件。 (为了简单起见,我使用了一个名为 Monitor 的文件)。
您想多谈谈您的“活动”吗?
Well, cron jobs is a solution. But not necessary in most cases.
If your script is doing something off the site (like sending an email or something), it must be a cron-job.
But...
I made a textbased rpg-game once where several actions were stored in the database waiting to get triggered at a specified time. I found out that it did not make any difference if the script fired at the time it should, or when the first person visiting the page after the time is beyond the timestamp. You could do these events before displaying the content of the page. (I used a file called monitor, to keep it simple).
Would you like to say more about your "event"?
除非您想编写守护进程/服务/等,否则 cron 将是您最好的选择。如果您需要比每分钟更频繁地运行作业,请使用锁定文件解决方案和循环脚本。
Unless you feel like writing a daemon/service/etc., cron would be your best bet. If you need a job ran more often than minutely, use a lockfile solution and a looping script.
好吧,其实不然,Crons 是你最好的选择。
除此之外,调用脚本,如果满足某些参数(例如经过的时间),则运行脚本。
Well not really, Crons are your best bet.
Other than that call a script, and if certain parameters are met such as time elapsed then run the script.