I wrote php script that runs node server:
<?php
file_put_contents("/var/www/executed.txt", "wykonano");
$url = "http://xxx.pl";
$http = curl_init($url);
curl_setopt($http, CURLOPT_RETURNTRANSFER, FALSE);
$result = curl_exec($http);
$http_status = curl_getinfo($http, CURLINFO_HTTP_CODE);
curl_close($http);
if ($http_status != "200" && $http_status != "301")
{
chdir("/var/www/xxx");
exec("nohup node server >/dev/null 2>&1");
}
When I run it from console: /usr/bin/php /var/www/node-apps.php Everything works grat. But I run this with cron and this file is executed but server doesnt run. Why ?
EDIT: cron job:
* * * * * /usr/bin/php /var/www/node-apps.php