I want to run a script 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 me a solution.
I want to run a script 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 me a solution.
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.
Sounds like your only solution would be "Poor Man's 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 man's 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
}
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)
See this and this.
(Edited to include content from the links.)
cron
). It can parse a crontab file and extract the job scheduling definitions into a MySQL database table. When it is time to run a scheduled job, it executes the job command in the crontab definition as PHP code as a separate process. The output of the job PHP code is also stored in a database table.That is how I do it
if(date('i', time())%5==0) {
// run this code
}
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.
I'm sure this tools can help you with your request:
SetCronJob - www.setcronjob.com
Cronless - cronless.com
EasyCron - www.easycron.com
Online Cron Jobs - www.onlinecronjobs.com
Corntab - www.corntab.com
getCron - www.getcron.com
However, it's not good idea to depend from another website.
Tanks to Google
My solution if your server is Linux. Make bash script:
#bin/bash
while [ true ]
do
//do whatever you want, use curl, lynx to your page...
sleep 5m
done
Run it and if your server would not reboot or script would not killed you will be fine.
This one isn't good solution, but works.
I would recommend this service, I used it today, and it seems to work well.
Cron-Job
and yes, it is Free!