简体   繁体   中英

Why won't cron execute my PHP script correctly?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM