Hi all,
I do not have access on my web host to setup a cron job. Does anyone have any ideas how I could get around this? I want to be able to run a php script every hour or so. I guess I could write a script that once run would keep connecting to a web address specific to a desired time interval. Any recommendations on this? Any PHP functions that could help me with this?
Thanks,'s
cronjob alternatives
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: cronjob alternatives
If it "no more than an hour" is necessary, you can do what's called a "poor man's cron". You setup a data storage format (text file, etc.), and every time a user visits, it checks the data. If it's older than (in your case) an hour, make it run the script, and update the data with the current time. If not, do nothing.
There are a couple of big problems with your other solution:
There are a couple of big problems with your other solution:
- If the server restarts or anything happens, poof, and you have no way of knowing it
- I don't know, but sleep()ing too long might make the script go past it's max execution time setting.
Re: cronjob alternatives
Sounds good. Thanks for the info. I think I will with the Task scheduler on Windows, but how do I direct it to the php script? Any idea?
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: cronjob alternatives
It looks like Windows doesn't have anything for this built in, so you'll have to install WGET for widows, or some other equivalent.
http://pages.interlog.com/~tcharron/wgetwin.html
http://pages.interlog.com/~tcharron/wgetwin.html
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: cronjob alternatives
If you want to run a local PHP script on your server, then a simply command along the lines of
[text] C:\path\to\php.exe "C:\Inetpub\wwwroot\mycron.php"[/text]
Should do the trick.
If you want to hit a remote website, then wget is probably your best bet.
[text] C:\path\to\php.exe "C:\Inetpub\wwwroot\mycron.php"[/text]
Should do the trick.
If you want to hit a remote website, then wget is probably your best bet.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: cronjob alternatives
Sounds like he's implying a remote file. Unless the script could just be run on his computer (unlikely)?spec36 wrote:I do not have access on my web host to setup a cron job...