getting a php file to run every night
Moderator: General Moderators
getting a php file to run every night
I just got word from my web hosting provider that they don't do custom cron jobs.
I need a php page to run unattended and automatically every night with some database functions in it. Is there any other way to automatically execute the page on a regular basis (24/7 at midnight) without using cron?
I need a php page to run unattended and automatically every night with some database functions in it. Is there any other way to automatically execute the page on a regular basis (24/7 at midnight) without using cron?
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
you might try... checking the time... and using an if statement
that would check the time and see if it was in a little range of midnight and refresh every 20 minutes
Code: Select all
<?
$var = time();
$lowtime = //10 minutes before;
$hightime = //10 minutes after;
if($var >= $lowtime && $var <= $hightime){
//do the script
}
echo "<META HTTP-EQUIV=Refresh CONTENT="1200; URL=$PHP_SELF">";
?>- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
Doh!
Is it possible to find some free host that does support cron jobs? If so, have the cron job on a free host access the script you need at midnight using wget or something like that.
Another option is to have your index page check the time. If it's midnight or beyond when the page is accessed, it can also run the script.
Just some ideas....
Later on,
BDKR
Is it possible to find some free host that does support cron jobs? If so, have the cron job on a free host access the script you need at midnight using wget or something like that.
Another option is to have your index page check the time. If it's midnight or beyond when the page is accessed, it can also run the script.
Just some ideas....
Later on,
BDKR
Yeah but who is going to run it?hob_goblin wrote:you might try... checking the time... and using an if statement
that would check the time and see if it was in a little range of midnight and refresh every 20 minutesCode: Select all
<? $var = time(); $lowtime = //10 minutes before; $hightime = //10 minutes after; if($var >= $lowtime && $var <= $hightime){ //do the script } echo "<META HTTP-EQUIV=Refresh CONTENT="1200; URL=$PHP_SELF">"; ?>
Just to clarify: my site is hosted on third-party web server (blacksun.ca) who won't do custom cron jobs.
I basically want to query a database for some specific criteria and if they are met, than an email is sent to the appropriate person. I had in mind to have it run automatically at midnight so that the email would be sitting in the inbox first thing in the morning for them.
Gotta head off for the weekend here, so won't be able to reply but if you have an idea, please post it here and I will check this forum Monday.
Thanks a bunch for your efforts -- this forum (ie. all you people out there) is/are great!
I basically want to query a database for some specific criteria and if they are met, than an email is sent to the appropriate person. I had in mind to have it run automatically at midnight so that the email would be sitting in the inbox first thing in the morning for them.
Gotta head off for the weekend here, so won't be able to reply but if you have an idea, please post it here and I will check this forum Monday.
Thanks a bunch for your efforts -- this forum (ie. all you people out there) is/are great!
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
-
rsbeaulieu
- Forum Newbie
- Posts: 6
- Joined: Tue Jul 02, 2002 6:02 am
- Location: NH
i dont know but i did that by doing this hehe
using the database to pull up a time greater than 2 days ago and have it do its thing in the else statement which would also update the DateAuto = NOW()

Code: Select all
$qry = mysql_query("SELECT DateAuto FROM siteauto WHERE TO_DAYS(NOW()) - TO_DAYS(DateAuto) >= 3");
if( mysql_num_rows($qry) == 0 ) {
exit();
}there is a nice easy way I have used to get around cron before. There is a site called http://www.internetseer.com/ who run a site downtime checking service for free. All you have to do is set up a little page that does your thing and they will visit the page every hour. This means you can have your script run every hour without using cron, simple. They even send you an e-mail to tell you if they were unable to connect to your page, you even get to see server outages as well for free along with having your script run for you.
Kind regards
Roger
Kind regards
Roger
- cheatboy00
- Forum Contributor
- Posts: 151
- Joined: Sat Jun 29, 2002 10:36 am
- Location: canada
- Contact: