2

I am trying to run a PHP script via a cron job on a Jelastic server. My cron/apache file looks like this.

*/1 * * * * /usr/bin/php /var/www/webroot/ROOT/php/cron.php

(there is a blank line after the last cronjob entry)

However the script is not called by the cron job. I have read the Jelastic documentation for cron jobs (http://docs.jelastic.com/cron-job) but this hasn't helped me resolve the issue.

Any help would be appreciated.

  • Have you tried running `/usr/bin/php /var/www/webroot/ROOT/php/cron.php` directly from the command prompt? If there's an error then it ought to show up. – edcs Apr 30 '14 at 07:10
  • Unfortunately I don't have access to the command prompt on this server so I can't try manually running the command. I know the script works as I have launched it via http and everything works as expected. – anothersanj Apr 30 '14 at 07:39

2 Answers2

0

As you said the script is accessible by HTTP, you could try using this cron job instead:

*/1 * * * * wget -q http://www.example.com/cron.php

This will perform at GET request to the cron.php file and disregard the output.

edcs
  • 3,847
  • 2
  • 33
  • 56
0

You can already get SSH access on the Layershift Jelastic PaaS: http://kb.layershift.com/jelastic-ssh-access

Assuming you're using a different provider, you might try writing cron output to a log file like

*/1 * * * * /usr/bin/php /var/www/webroot/ROOT/php/cron.php >> /var/log/httpd/cron.log

And/or you can try to mail the output to yourself (but beware mailing caveats; without a public IP your mail will "originate" from the physical server's IP instead, and that may or may not have a valid PTR record defined or be on blacklists etc. - so basically there's a good chance your spam filters may reject the email); just add this line to your crontab:

MAILTO=you@youremail.com

Damien - Layershift
  • 1,508
  • 8
  • 15