Im writing a php cron script that needs to run a url
After some database modifications the php script needs to execute an url
$url = 'http://server.domain.com/cronjob.php?idorder='.$orderid.'&idcustomer='.$idklant;
$fp = fopen(dirname(__FILE__).'/../data/errorlog.txt', 'w');
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
curl_setopt ($ch, CURLOPT_CONNECT_ONLY);
//curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 0);
//curl_setopt ($ch, CURLOPT_AUTOREFERER, true);
//curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
// debug
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, $fp);
//
$exec = curl_exec($ch);
curl_close($ch);
echo $url.'<br>';
The error log shows * About to connect() to server.domain.com port 80 (#0)
- Trying xxx.xxx.xxx.xxx... * Connection timed out
- couldn't connect to host
- Closing connection #0
But when I run the $url direct in a browser window it works