tags:

views:

458

answers:

5

I know this question is asked about hundred of times, but

I want to run a scirpt every 5 minutes on server, I have not any type of administrate privileges to do cron job etc.

I am not good php programmer so this question may look strange, but if you understand please tell some solution.

Thanks.

+1  A: 

See this and this.

wallyk
+1  A: 

Sounds like your only solution would be "Poor Mans Cron".

What you do is create a script that you place on top of every page that only runs every 5 minutes. It won't be guaranteed to run every 5 minutes though. As it requires someone to visit the pages with the "poor mans cron" and if no one visits for over 5 minutes then it won't run until someone does.

Some example code:

<?php
 // load the last run time from a file, database, etc
 if(time() >= $last_run + (60 * 5)) { // 60 * 5 is 5 minutes
     // do your task here
     // save the last run time to a file, database, etc
 }
MitMaro
A: 

Something like:

ini_set('max_execution_time', 'sometime'); 
while(1){
    //do something
    sleep(sometime);
}

Although I don't recommend doing this. Time to move to a server that meets your needs.

pcp
+1  A: 

Here's another 'hack'. Since you can't run cron on the machine where the script is, maybe you can run cron on another machine.

If you can...setup a cron job to run every 5 minutes...The job can be a simple PHP script that calls your other PHP script. You can use cURL to 'call' your script (if that script is being served up by a Web Server)

milesmeow
+1  A: 

I use webcron.org wich is an affordable online service. Advantage for me is that I then have an overview of all scheduled tasks, on all servers.

barrycarton
Thanks barrycarton but if you know any similar service that is free.Again Thanks for your answer..
Hitesh Chavda
Ah! Thanks to all
Hitesh Chavda
Hi I found similar free service http://www.mywebcron.com/Thanks again all repliers
Hitesh Chavda