Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Comments
Imran_ 23-Dec-13 13:01pm    
Is it a Scheduled task which repeats on a time interval or your php-script is doing a Real time update to a client?

You can run any script with php. Example
#php generatereport.php param1 param2

Now to run this thing periodicaly just use scheduler.
 
Share this answer
 
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
 
Share this answer
 
Comments
Er. Tushar Srivastava 29-Dec-13 13:58pm    
Please tell me one good reason why has this answer down-voted 5-6 times till now?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900