简体   繁体   中英

Run a PHP file in a cron job using Control Panel

I am trying to run a PHP script using a cron job within CPanel - is this the correct syntax: /home/username/public_html/cron.php

But i dont get mail from my file cron.php,i gave every 5 minue option.

Code in cron.php

<?php
$to  = 'test@gmail.com';
$subject = 'Whole Sale VoIP Provider';
$message = "Name"; 
$content='test@test.com/';
$Headers = "From:$content\r\n" . 
"Reply-To: $content \r\n" . 
"Content-type: text/html; charset=UTF-8 \r\n"; 
$Headers.= "MIME-version: 1.0\n";
$mail=mail($to,$subject, $message, $Headers);
?>

You should try the following, Defiantly It will work for you:

Your crontab should be like this:

SHELL=/bin/bash
HOME=/
*/1 * * * * /usr/bin/php /var/www/senmail.php >> /var/www/log.txt

It will execute your php file every minute.And you should also try running your file in browser.

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