0
我们在Drupal项目中使用Drupal。发送邮件我们计划使用cronjob的功能。我创建了自定义模块,并创建了hello_cronapi()挂钩函数。我的cron名称在下面的路径中查看管理面板。CronJob没有自动运行Drupal7
首页»管理»配置»系统
在管理控制台的cronsetting页面时检查强制运行按钮的cron运行。我已经把我的cronjob运行每15分钟,但它不会自动运行(每15分钟)
function hello_cronapi($op, $job = NULL){
$items['example_sendmail_cron'] = array(
'description' => 'Send mail with news',
'rule' => '* * * * *', // Every 5 minutes
);
$items['example_news_cron'] = array(
'description' => 'Send mail with news',
'rule' => '*/15 * * * *', // Every 5 minutes
// i must call: example_news_fetch('all')
'callback' => 'example_news_cron',
'arguments' => array('all'),
);
return $items;
}
功能example_sendmail_cron(){
echo "Company";
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt, FILE_APPEND | LOCK_EX);
$txt = "Jane Doe\n";
fwrite($myfile, $txt, FILE_APPEND | LOCK_EX);
fclose($myfile);
exit;
}
function example_news_cron() {
echo "Company";
$myfile = fopen("newfile2.txt", "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt, FILE_APPEND | LOCK_EX);
$txt = "Jane Doe\n";
fwrite($myfile, $txt, FILE_APPEND | LOCK_EX);
fclose($myfile);
exit;
}
在上面的cronjob是创建一个文件并将内容放入文件中。但文件不是创建的
你在使用Elysia cron吗? https://www.drupal.org/project/elysia_cron – Fky