edição final: movi isso para Erro 406 com o trabalho GET Cron ?
EDIT 4:
Estou recebendo uma página de erro 406 com este cron!
aqui é o crontab (copiado do cPanel):
* * * * * GET https://abc.com/cron/sendBulletinEmails.php >>
/home/abc/public_html/cron/logs/sendBulletinEmails.log
aqui está o log:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>406 Not Acceptable</title>
</head><body>
<h1>Not Acceptable</h1>
<p>An appropriate representation of the requested resource /cron/sendSurveyEmails.php could not be found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>
Eu tenho php configurado em uma máquina virtual rodando linux. Eu configurei meu crontab para:
* * * * * { cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} |/usr/bin/logger -t sendQueuedEmails
no entanto, o cron não parece estar em execução. não está registrando nenhum erro e não está enviando e-mails. você sabe o que está errado?
obrigado!
EDIT 3:
Encontrei os logs do cron em execução. nada parece estar errado, mas ainda não está funcionando ou produzindo nada!
Aug 5 16:20:01 fiqsrv1 CRON[18543]: (cgurnik) CMD ({ cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} |/usr/bin/logger -t sendQueuedEmails)
Aug 5 16:21:01 fiqsrv1 CRON[18549]: (cgurnik) CMD ({ cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} |/usr/bin/logger -t sendQueuedEmails)
Aug 5 16:22:01 fiqsrv1 CRON[18554]: (cgurnik) CMD ({ cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} |/usr/bin/logger -t sendQueuedEmails)
Aug 5 16:23:01 fiqsrv1 CRON[18559]: (cgurnik) CMD ({ cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} |/usr/bin/logger -t sendQueuedEmails)
Aug 5 16:24:01 fiqsrv1 CRON[18564]: (cgurnik) CMD ({ cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} |/usr/bin/logger -t sendQueuedEmails)
Aug 5 16:25:01 fiqsrv1 CRON[18569]: (cgurnik) CMD ({ cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} |/usr/bin/logger -t sendQueuedEmails)
Aug 5 16:26:01 fiqsrv1 CRON[18574]: (cgurnik) CMD ({ cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} |/usr/bin/logger -t sendQueuedEmails)
Aug 5 16:27:01 fiqsrv1 CRON[18595]: (cgurnik) CMD ({ cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} |/usr/bin/logger -t sendQueuedEmails)
Aug 5 16:28:01 fiqsrv1 CRON[18601]: (cgurnik) CMD ({ cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} |/usr/bin/logger -t sendQueuedEmails)
Aug 5 16:29:01 fiqsrv1 CRON[18610]: (cgurnik) CMD ({ cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} |/usr/bin/logger -t sendQueuedEmails)
EDIT 2:
agora, quando eu executo o script, ele não gera nada.
Eu pensei em postar o script para mostrar que ele sempre gera algo, e é por isso que estou confuso quando o executo e nada sai (sem erros, sem saída)
<?php
require '../includes/common.php';
/*
* check that this cron job isn't already running (it can take a long time if there is a large email load, which it is meant for)
* if it is running, end the script
* if it is not running, continue
* set the global variable for this cron job to on
* get all queued emails that have their time to be sent in the past (and so they should be mailed out now)
* loop through them, checking to see if the user is still set to receive the email, and if so, sending it to them
* set the global variable for this cron job to off
*
* JUST IN CASE: put the script in a try catch after the email cron is set to running in globalvars so that it is always reset, even upon failure
*/
// check that this cron job isn't already running (it can take a long time if there is a large email load, which it is meant for)
if(GlobalVars::isEmailCronRunning()) {
echo "Already running! Aborted.";
exit; // if it is running, end the script
}
// if it is not running, continue
// set the global variable for this cron job to on
GlobalVars::set(GlobalVars::VAR_IS_EMAIL_CRON_RUNNING, 1);
try {
// get all queued emails that have their time to be sent in the past (and so they should be mailed out now)
$queuedEmails = Emails::getAllQueuedToSend();
// loop through them, checking to see if the user is still set to receive the email, and if so, sending it to them
$numEmailsSent = 0;
$numEmailsRecalled = 0;
foreach($queuedEmails as $email) {
if(Emails::shouldBeSentToUser($email)) {
Emails::sendQueuedEmail($email[Emails::id]);
$numEmailsSent++;
} else {
Emails::update($email[Emails::id], array(Emails::result => Emails::RESULT_NOT_SENT) );
$numEmailsRecalled++;
}
}
// set the global variable for this cron job to off
GlobalVars::set(GlobalVars::VAR_IS_EMAIL_CRON_RUNNING, 0);
} catch (Exception $e) {
// set the global variable for this cron job to off
GlobalVars::set(GlobalVars::VAR_IS_EMAIL_CRON_RUNNING, 0);
echo "Error: " . print_r($e);
}
if($numEmailsSent || $numEmailsRecalled) {
$details = "Sent " . $numEmailsSent . ". Recalled " . $numEmailsRecalled . ".";
echo nl2br($details);
ActionLogs::add(ActionLogs::CAT_CRON_JOBS, ActionLogs::TYPE_CRON_EMAILER_RUN, $details);
} else {
echo "No emails were sent.";
}
?>
EDIT: eu tentei executá-lo e tenho o seguinte:
Warning: require_once(/includes/Swift-4.0.6/lib/swift_required.php): failed to open stream: No such file or directory in /var/www/includes/common.php on line 31
Fatal error: require_once(): Failed opening required '/includes/Swift-4.0.6/lib/swift_required.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/includes/common.php on line 31
como posso definir o caminho de inclusão para que isso funcione tanto no meu servidor de depuração Linux como no meu servidor Linux ao vivo?