我想多次运行一个php脚本,它应该每12秒运行一次。 [英] I want to run a php script multiple times and it should run every 12 seconds.

查看:83
本文介绍了我想多次运行一个php脚本,它应该每12秒运行一次。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在Linux中开发我的网站,我想多次运行php脚本,它应该每12秒运行一次。我为此设置了cron,但是cron可以每1分钟(最少)运行任何脚本。



我应该怎么做。

Hello i am developing my website in Linux and i want to run a php script multiple times and it should run every 12 seconds. I set cron for do this but cron can run any script in every 1 minute (minimum) .

how should i do this.

推荐答案

您可以使用php运行任何脚本。示例

#php generatereport.php param1 param2



现在定期运行此事只需使用调度程序。
You can run any script with php. Example
#php generatereport.php param1 param2

Now to run this thing periodicaly just use scheduler.


嗨朋友,



我只能给你这个想法。但它可能会增加服务器负载。我的想法使用node.js.



你需要做的是:



1.创建一个在请求网页时获取请求(所有浏览器都创建它),在node.js中



2.将网址设为http://localhost/criticalscript.php(这个网址只是一个演示版)。你实际上必须每隔12秒调用你想要运行的脚本。



3.在node.js中创建一个超时函数并每12秒调用一次每12秒请求一次脚本。



4.会发生什么,脚本每12秒在您的服务器上运行。



虽然是,你必须具有服务器的root访问权限(如果我没有错)。但我对此并不是100%肯定。



如需进一步的想法,请访问这个链接。



希望它有所帮助:)请评价我的答案并标记为已解决如果它解决了你的问题问题:)



有问候

Tushar Srivastava
Hi Friend,

I can only give you idea regarding this. It may increase the server load though. My idea uses node.js.

What you have to do is :

1. Create a GET request (all the browsers create it while requesting a webpage), in node.js

2. Put the url as http://localhost/criticalscript.php (This url is a demo only). You actually have to call your own script that you want to run every 12 sec.

3. Create a timeout function in node.js and call it every 12 sec to request that script every 12 sec.

4. What happens is, the script is run on your server every 12 sec.

The point though is, you must have root access of the server to do so (if I am not wrong). Yet I am not 100% sure about this.

For further ideas Please visit this link.

Hope it helped :) Please rate my answer and mark as solved if it solved your problem :)

With Regards
Tushar Srivastava


这篇关于我想多次运行一个php脚本,它应该每12秒运行一次。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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