[tutorial] crontab queue processing with php-cgi

Solutions for other phplisters - Questions go in the questions and problems forum

Moderators: Dragonrider, J_S, Hernol, vancoovur, H2B2, bevan, Heritage

[tutorial] crontab queue processing with php-cgi

Postby error4o4 » 10:07pm, Tue 19 May, 2009

After trying lots of different stuff from various forum threads and documentation pages, I finally got it to work ! Here is how you can setup a crontab to process the phplist queue when you only have acces to php cgi.


1. Make sure you are using PHP CGI

Type this command : php -v

If the output is something like this, you are using PHP CGI.
PHP 5.2.9 (cgi) (built: Mar 17 2009 15:11:50)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

If the output says "PHP x.x.x (cli)", you are lucky, you have a PHP CLI binary, so you don't need this help. Just reads the docs about setting up the crontab.


2. Setup config.php

You have to understand that PHPlist cannot tell if you are using PHP CGI from the command line, from the crontab, or from the Internet, using your web browser.

So, you have to set this setting to 1 :
define ("MANUALLY_PROCESS_QUEUE",1);

Then, you have to set the throttling settings.
I use the following settings because my host allows me to send about 1000 messages per hour, and the crontab is called every hour. As you can see, I set the throttle to 0 because my host has a max_execution_time of 30 seconds, so I need PHPlist to queue as much messages as it can in 30 seconds.

Adjust this according to your own needs :
define("MAILQUEUE_BATCH_SIZE",1000);
define("MAILQUEUE_BATCH_PERIOD",3000);
define('MAILQUEUE_THROTTLE',0);

Note : You don't have to care about the $commandline_users setting : it is not used, since you're not using php-cli.


3. Setup the user

You are going to access PHPlist with an admin username and password.
So, create a new admin in the PHPlist user interface.
Modify this admin's rights so that message/processqueue permission is set to "all".
Warning : creating the new admin as a superadmin doesn't work, you have to create a regular admin and check this permission.


4. Test your setup and enable crontab

Try the following command :
/path/to/php /path/to/phplist/admin/index.php page=processqueue login=xxx password=yyy

You shall see HTML code, if this code finishes with Javascript stuff saying "processing queue" and stuff like that, congrats, you did it ! Now you just have to add this command to your crontab.


5. Troubleshooting

You have to read carefully the HTML code you get as a result of your command.
If it says something like "you are not authorized to acces this page", it means that you forgot to set the message/processqueue permission to "all" in step 3.
error4o4
PL Nut
 
Posts: 17
Joined: 6:51am, Tue 08 Apr, 2008

Re: [tutorial] crontab queue processing with php-cgi

Postby H2B2 » 1:59am, Wed 20 May, 2009

Very useful tutorial. Thanks!
H2B2
phpList Guru
 
Posts: 5890
Joined: 1:51am, Wed 15 Mar, 2006

Re: [tutorial] crontab queue processing with php-cgi

Postby FabioLima » 4:07pm, Thu 02 Jul, 2009

Hi guys,
This dont worked for me:
phplist/admin/index.php page=processqueue login=xxx password=yyy


But with this:
phplist/admin/?page=processqueue login=xxx password=yyy

Work!
FabioLima
PL Nut
 
Posts: 17
Joined: 7:14pm, Fri 12 Jun, 2009

Re: [tutorial] crontab queue processing with php-cgi

Postby nevindesign » 7:08am, Tue 01 Sep, 2009

been racking my brain until i found this. FANTASTIC! easy to follw, worked like a charm!

thanks error4o4
nevindesign
phplist newbie
 
Posts: 2
Joined: 6:50am, Tue 01 Sep, 2009


Return to Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 2 guests