Forum Moderators: phranque
I run my own web server with php where i host pictures and such for friends. Since it's not 100% reliable (due to what we think are power spikes that may keep frying our hardware :( ), I have another hosting service that runs my important website and forums.
On the important website and forums, I have added a program (phpAdsNew) that must have a php script run every hour. But, I don't have cron access to that server.
I'm wondering if I can set up my own web server to have a cron job that will run and excecute that php script on the other server ever hour.
Now I'm still new to servers and cron and such, and I'm not sure if I have PERL on my server (I run Suse Linux). Or what other method I could use to execute a program that will allow the remote php script to be hit every hour.
I appreciate any help! Thanks.
If you have *nix OS on your server at home, you can simply add
wgetto your cron file.
wget -q -t 5 --delete-after http*//www.example.com/your.php
From wget manual:
-q: This option is the opposite of verbose, making Wget completely quiet.
-t num: Set number of retries to num. Specify 0 or `inf' for infinite retrying.
--delete-after: This option tells Wget to delete every single file it downloads, after having done so. It is useful for pre-fetching popular pages through PROXY, e.g.
[edit reason]Added greeting[/edit reason]
[edited by: moltar at 3:28 pm (utc) on April 27, 2005]
Almost all servers have perl, but you could do a php equvalent of
$result = `curl [example.com...]
if (! $result =~ /<html>/i/) { &log("didn't work at $thisTime"); }
else { &log("Ran successfully at $thisTime"); }
where &log is a routine you have to log your cron requests, and $thisTime is a variable you previously created to store the server time in.
The backticks ` are an equivalent of "run this command," equivalent to perl qx"[command]" or semi-equivalent to perl system([command]).
If you set up cron_me.php to print out only a 1 when it runs sucessfully, you could do
if (! ($result == 1)) ....
You could use other methods than curl, as it only works on linux, but I think this will get you started toward a solution.