最近想用cron去执行cron job,但是我必须要使用PHP网页去执行cron(因为启动时间
是计算出来的,无法用cPanel直接输入固定的时间),就得必须用exec或system函数来执
行指令,但是不知为何就是无法起作用,请问是哪里有问题了? 是不是因为我租虚拟主机
的关系,管理者把exec和system函数给关掉了? 以下是我的PHP码:
mail.php:
<?php
$headers = 'From:webmaster@example.com' . "\r\n" .
'Reply-To:webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail("email@example.com", "Subject", "Message Body", $headers);
?>
run.php:
<?php
$path = dirname(__FILE__);
$cron = $path . "/mail.php";
echo exec("49 0 20 12 0 php -q ".$cron." >/dev/null 2>&1"); //令12月20日星
期日上午12:49执行mail.php(发送Email至email@example.com)
?>
(假设mail.php和run.php位于同一目录下)