Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why won't cron execute my PHP script correctly?

Tags:

php

cron

I've got a PHP script (just a simple script) and I'm trying to get it to run as a cronjob. Every time it executes the PHP script, I receive a mail with the PHP script itself.

How can I resolve this? I've searched on Google a lot but I can't find anything that works.

like image 593
Jevgeni Geurtsen Avatar asked Feb 10 '13 10:02

Jevgeni Geurtsen


1 Answers

In your DirectAdmin panel go to 'cronjobs' section, I assume you already configured time interval for your cronjob, so you just need to adjust 'command' option, so try:

First option:

/usr/bin/php -f /home/your_user/public_html/your_script.php

This way you will call php script with php interpreter.

Second option:

lynx -source http://yourdomain.com/your_script.php

This way you will execute text based web browser lynx and open desired url so that php script can be run. Lynx is installed by default on most linux servers.

Also I believe that there is a option in DirecAdmin cronjobs section called 'Prevent email' check that so that you don't receive emails.

like image 141
Develoger Avatar answered Sep 30 '22 16:09

Develoger