[tutorial] crontab queue processing with php-cgi

Solutions for other phpList version 2 users
Forum rules
Please do not ask questions here, this is for Solutions you have discovered or come across.

[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: 20
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
Moderator
 
Posts: 7188
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: 18
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

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

Postby indidginus » 1:26pm, Mon 19 Apr, 2010

Hi guys,

I don't understand steps 4 and 5 - where are you meant to type that text? Many thanks.

Michael.
indidginus
PL Nut
 
Posts: 44
Joined: 11:27am, Sun 18 Apr, 2010
Location: Cape Town, South Africa.

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

Postby error4o4 » 4:02pm, Mon 19 Apr, 2010

indidginus wrote:I don't understand steps 4 and 5 - where are you meant to type that text? Many thanks.

This is the command to call PHP and have it run phplist's "processqueue" process, it should be entered in your UNIX shell.
error4o4
PL Nut
 
Posts: 20
Joined: 6:51am, Tue 08 Apr, 2008

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

Postby Dragonrider » 6:03pm, Mon 19 Apr, 2010

I have to admit, I don't even understand step 1!! Where (and how) do I type "Type this command : php -v" ??
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.12 (3 February 2015) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3460
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom

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

Postby error4o4 » 7:25pm, Mon 19 Apr, 2010

Dragonrider wrote:I have to admit, I don't even understand step 1!! Where (and how) do I type "Type this command : php -v" ??

In your UNIX shell account.
error4o4
PL Nut
 
Posts: 20
Joined: 6:51am, Tue 08 Apr, 2008

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

Postby indidginus » 7:41pm, Mon 19 Apr, 2010

error4o4 wrote:This is the command to call PHP and have it run phplist's "processqueue" process, it should be entered in your UNIX shell.


Ah OK, thanks man. I guess I'll have to ask my host to help with that then?
indidginus
PL Nut
 
Posts: 44
Joined: 11:27am, Sun 18 Apr, 2010
Location: Cape Town, South Africa.

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

Postby indidginus » 7:41pm, Mon 19 Apr, 2010

Dragonrider wrote:I have to admit, I don't even understand step 1!! Where (and how) do I type "Type this command : php -v" ??


I'm glad I'm not the only one!!!! :lol:
indidginus
PL Nut
 
Posts: 44
Joined: 11:27am, Sun 18 Apr, 2010
Location: Cape Town, South Africa.

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

Postby Dragonrider » 8:04pm, Mon 19 Apr, 2010

error4o4 wrote:
Dragonrider wrote:I have to admit, I don't even understand step 1!! Where (and how) do I type "Type this command : php -v" ??

In your UNIX shell account.

I have cPanels on my hosting accounts. Never seen a UNIX shell on any of these.... :?:
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.12 (3 February 2015) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3460
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom

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

Postby error4o4 » 8:18pm, Mon 19 Apr, 2010

Well if you guys do not have access to your shell account, then this will not work for you.
If you are using cPanel, I suggest you visit the [how to] get phplist working with cpanel cron thread.
error4o4
PL Nut
 
Posts: 20
Joined: 6:51am, Tue 08 Apr, 2008

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

Postby indidginus » 8:34pm, Mon 19 Apr, 2010

It seems my host doesn't support cron jobs apparently :( What is the best way for me to set up PHPList in this case? I have about 750 people on my list.....
indidginus
PL Nut
 
Posts: 44
Joined: 11:27am, Sun 18 Apr, 2010
Location: Cape Town, South Africa.

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

Postby nkf » 2:35pm, Mon 19 Jul, 2010

I can get this to work when I run on the command line but I dont seem to be able to run it as a cron job. My cron job looks like this: 27 * * * * /path/to/php /path/to/phplist/admin/index.php page=processqueue login=xxx password=yyy

I have tried another example of a cron job with success ( 27 * * * * cp /path/to/helloworld.php /path/to/hello.php)

Does anyone have any ideas what I am doing wrong - I am getting desperate!

I am using the 1and1 server.

Any help very gratefully received....
nkf
phpList newbie
 
Posts: 1
Joined: 2:28pm, Mon 19 Jul, 2010

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

Postby dorianz » 12:12pm, Wed 01 Sep, 2010

Look in cron's log what it says.
astigmatism
P iCore7 266 16gig/ram
dorianz
phpList newbie
 
Posts: 1
Joined: 12:11pm, Wed 01 Sep, 2010

Next

Return to Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest