1

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
mitch
  • 2,235
  • 3
  • 27
  • 46
  • What port does the node app use? You need root access to run a node app on a port < 1024: http://stackoverflow.com/questions/9164915/node-js-eacces-error-when-listening-on-most-ports – verybadalloc Jun 16 '13 at 13:45
  • The port: 3000. I have added cron task as root anyway – mitch Jun 16 '13 at 13:46
  • Try to su into root (sudo su root, not sudo -s) and execute exactly what's written in the script cd /var/www/xxx (enter) nohup node server) – Lorenz Jun 16 '13 at 14:37

0 Answers0