what is the better schedule for CRON?

Solutions for other advanced phplisters

what is the better schedule for CRON?

Postby pantera » 12:30am, Mon 27 Jul, 2009

Since the limit of my server is 100 messages per hour, I configured my config.php file to send 60 messages/hour, then I have 40 messages to use myself.
The config.php file is:

define("MAILQUEUE_BATCH_SIZE",0);
define("MAILQUEUE_BATCH_PERIOD",3600);
define('MAILQUEUE_THROTTLE',60);


I have right now a cron job working OK, but I am getting the following messages, each hour:

Started
Processing has started, 1 message(s) to process.
Processing message 56
Looking for users
Found them: 61363 to processProcess Killed by other process
Process Killed by other process
Script stage: 5
60 messages sent in 3610.70 seconds (59 msgs/hr)


What call my attention is the expression "PROCESS KILLED BY OTHER PROCESS".
My cron job is scheduled for:

15 minutes
every hour
every day
every month
every week day


I'm thinking that the 15 MINUTES may be wrong, and is causing the "process killed by other process". Maybe it is better to change to 30 minutes or more, what do you think?
thanks.
pantera
phpLister
 
Posts: 10
Joined: 12:29pm, Fri 17 Jul, 2009

Re: what is the better schedule for CRON?

Postby pantera » 11:52am, Mon 27 Jul, 2009

This is what is in the phplist - log of events page. I changed the cron schedule to sent messages each 50 minutes.
After that the system messages stoped, I am worring if the messages are still being sent.
The messages page indicates an increase in the number of messages sent, each time I open the page, the number is higher. But I am worring because the system messages stoped.

5351 del processqueue 2009-07-27 07:50:03 Running commandline, quitting. We'll find out what to do in the next run.
5350 del processqueue 2009-07-27 07:50:02 A process for this page is already running and it was still alive 92 seconds ago
5349 del processqueue 2009-07-27 06:50:02 Running commandline, quitting. We'll find out what to do in the next run.
5348 del processqueue 2009-07-27 06:50:01 A process for this page is already running and it was still alive 94 seconds ago
5347 del processqueue 2009-07-27 05:50:02 Running commandline, quitting. We'll find out what to do in the next run.
5346 del processqueue 2009-07-27 05:50:01 A process for this page is already running and it was still alive 96 seconds ago
5345 del processqueue 2009-07-27 04:50:03 Running commandline, quitting. We'll find out what to do in the next run.
5344 del processqueue 2009-07-27 04:50:02 A process for this page is already running and it was still alive 2 seconds ago
5343 del processqueue 2009-07-27 03:50:02 Running commandline, quitting. We'll find out what to do in the next run.
5342 del processqueue 2009-07-27 03:50:01 A process for this page is already running and it was still alive 73 seconds ago
5341 del processqueue 2009-07-27 02:50:02 Running commandline, quitting. We'll find out what to do in the next run.
5340 del processqueue 2009-07-27 02:50:01 A process for this page is already running and it was still alive 75 seconds ago
5339 del processqueue 2009-07-27 01:50:03 Running commandline, quitting. We'll find out what to do in the next run.
5338 del processqueue 2009-07-27 01:50:02 A process for this page is already running and it was still alive 79 seconds ago
pantera
phpLister
 
Posts: 10
Joined: 12:29pm, Fri 17 Jul, 2009

Re: what is the better schedule for CRON?

Postby ysa » 12:11pm, Wed 02 Sep, 2009

Hello pantera.

I met same trouble.
So, I'm checked source , and The problem was solved.

Please see file:processqueue.php.
The following parts exist.

function sendEmailTest ($messageid,$email) {
global $report;
if (VERBOSE)
output($GLOBALS['I18N']->get('(test)').' '.$GLOBALS['I18N']->get('Would have sent').' '. $messageid .$GLOBALS['I18N']->get('to').' '. $email);
else
$report .= "\n".$GLOBALS['I18N']->get('(test)').' '.$GLOBALS['I18N']->get('Would have sent').' '. $messageid.$GLOBALS['I18N']->get('to').' '. $email;
}
# we don not want to timeout or abort
$abort = ignore_user_abort(1);
set_time_limit(600);
flush();

output($GLOBALS['I18N']->get('Started'),0);
# check for other processes running
if (!$send_process_id) {
$send_process_id = getPageLock();
}
・・・
(Omission)
・・・
# check if we have been "killed"
$alive = checkLock($send_process_id);
if ($alive)
keepLock($send_process_id);
else
ProcessError($GLOBALS['I18N']->get('Process Killed by other process'));

IF $alive equal "0", Error "Process Killed by other process" occurs.
The $alive decided funciton getPageLock() exist in lib.php.
The following parts exist.

function getPageLock() {
global $tables;
$thispage = $GLOBALS["page"];
※2 $running_req = Sql_query("select now() - modified,id from ".$tables["sendprocess"]." where page = \"$thispage\" and alive order by started desc");
$running_res = Sql_Fetch_row($running_req);
$waited = 0;
while ($running_res[1]) { # a process is already running
※1 if ($running_res[0] > 600) {# some sql queries can take quite a while
# process has been inactive for too long, kill it
Sql_query("update {$tables["sendprocess"]} set alive = 0 where id = $running_res[1]");

} else {
output ($GLOBALS['I18N']->get('A process for this page is already running and it was still alive').' '.$running_res[0].' ・・・
・・・
(Omission)
・・・

※1
If 600 seconds or more have passed since process under start started,
$alive = 0 by SQL update.
But, SQL that calculates process uptime (※2) is incorrect.
So, I mends it

× $running_req = Sql_query("select now() - modified,id from ".$tables["sendprocess"]." where page = \"$thispage\" and alive order by started desc");

○ $running_req = Sql_query("select UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(modified),id,now(),modified from ".$tables["sendprocess"]." where page = \"$thispage\" and alive order by started desc");

The problem was solved by this.
Please refer.
:)
ysa
phpList newbie
 
Posts: 1
Joined: 11:21am, Wed 02 Sep, 2009


Return to Advanced Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 2 guests