larger smaller normal text version of this page

Revision [1133]

Last edited on 2007-05-20 02:01:17 by AlStillero [Added "Tips & Tricks from the forum"]
Additions:
===Other Tips & Tricks from the forum===
- [[http://forums.phplist.com/viewtopic.php?t=9856 Solution for the user environment variable issue]]


Revision [986]

Edited on 2006-12-04 19:25:08 by AlStillero [added commandline script example]
Additions:
===Commandline script that logs the start and end of processing===
**Settings in config.php**
%%(php)
define("MAILQUEUE_BATCH_SIZE",50);
define("MAILQUEUE_BATCH_PERIOD",500); // irrelevant with CLI and cron
define('MAILQUEUE_THROTTLE',2);
$commandline_users = array("admin","listprocessor");%%
**Commandline script**
%%(php)
#!/bin/bash
# identify the config file for your installation
CONFIG=/var/www/lists/config/config.php
ISCLI=TRUE
[ -z $USER ] && USER=admin
PROCESS=$$
export CONFIG ISCLI USER
LOGFILE=/var/www/lists/log/phplist.log
echo "Process $PROCESS started on 'date'">>$LOGFILE
/usr/bin/php /var/www/lists/admin/index.php $*>> $LOGFILE 2>&1
echo "Process $PROCESS ended on 'date'">>$LOGFILE
The definition of the users is important, otherwise phplist will not allow processing.
**Cron job**
The next step is to set up the cron job and execute the script every 10 minutes (remember to change the paths):
%%10 * * * * /var/www/phplist/lists/phplist -pprocessqueue -c/var/www/lists/config/config.php%%
Source: [[http://www.contentschmiede.de/archiv/2006/08/07/das_newsletter-tool_phplist/#cron Die ContentSchmiede]]


Revision [876]

Edited on 2006-10-20 21:15:27 by AlStillero [minor edit]
Additions:
After edited the phplist file to reflect the locations of my config.php and admin/index.php file, I inserted a check in my "phplist" commandline file which would set the USER environment variable (if it wasn't already set).
15 * * * * /usr/local/scripts/phplist -pprocessqueue
Finally I made sure the phplist file is executable (chmod 755). Source: [[http://forums.phplist.com/viewtopic.php?p=8040#8040 Forum post by cafamily]]
Deletions:
15 * * * * /usr/local/scripts/phplist -p processqueue
I then edited the phplist file to reflect the locations of my config.php and admin/index.php file.
I then inserted a check in my "phplist" commandline file which would set the USER environment variable (if it wasn't already set). Finally make sure the phplist file is executable (chmod 755). Source: [[http://forums.phplist.com/viewtopic.php?p=8040#8040 Forum post by cafamily]]


Revision [875]

Edited on 2006-10-20 21:06:09 by AlStillero [minor edit]
Additions:
%%(php)$commandline_users = array("listprocessor","any other","users","you want","to set");%%
Deletions:
%%(php)$commandline_users = array("listprocessor","any other","users,"you want","to set");%%


Revision [874]

Edited on 2006-10-20 21:04:50 by AlStillero [Preparation of the page and one addition]
Additions:
==[[PhplistDocumentation Phplist Documentation]] » [[MessageFunctionsInfo Message functions]] » [[ProcessQueueInfo Process the message queue]] » ==
=====Commandline Script Examples =====
//This page provides some examples of commandline scripts applied by Phplist users. You are welcome to add your commandline script. Please include a brief description of what it does.//

===Commandline script that checks for running processes===

%%(php)#!/bin/bash

#Just check if the script is running if it is about otherwise run the script
if [ `ps aux |grep phplist | grep -c -v 'grep'` -eq 0 ]
then
echo "" >> /var/log/list.log
echo "`date`" >> /var/log/list.log
/usr/local/bin/phplist -pprocessqueue >> /var/log/list.log
else
exit 0
fi
%%
This is a little bash script that I use to get around the problem of having the process queue already running when the cronjob calls it. I don't actually call the phplist command from the cronjob but rather call this shell script which just checks to see if phplist is running and if it is exits otherwise if it isn't it will call the phplist -processqueue command. I have noticed that phplist takes a lot out of mysql so you definitely wouldn't want to have 2 process queues running at once. I imagine you could write a batch file that does the same thing pretty easily. Source: [[http://forums.phplist.com/viewtopic.php?p=8877#8877 Forum post by habbers]]


===Commandline script that checks for user variable===

%%(php)#!/bin/bash

# Place config data in environment
export CONFIG

# Check the USER environment variable is set
if [$USER]; then
echo found USER variable
else
USER=listprocessor
export USER
fi

# run the PHPlist index file with all parameters passed to this script
/usr/bin/php /home/website/public_html/lists/admin/index.php $*

%%
I relocated this to a location away from my public html files ( say /usr/local/cron_scripts ) and point to this in my cronjob line:

%%(php)# every hour at 15 minutes past we process the queued messages
15 * * * * /usr/local/scripts/phplist -p processqueue

%%
I then edited the phplist file to reflect the locations of my config.php and admin/index.php file.
I found no need to include any login or password variables in the call to the admin/index.php file. The problem for me was that a cronjob does not have a USER environment variable set and it is from this that the admin/index.php file checks against commandline_users.
The solution was to create a pseudo (non existent) user in the commandline_users variable in the config.php file. so ...

%%(php)$commandline_users = array("listprocessor","any other","users,"you want","to set");%%
I then inserted a check in my "phplist" commandline file which would set the USER environment variable (if it wasn't already set). Finally make sure the phplist file is executable (chmod 755). Source: [[http://forums.phplist.com/viewtopic.php?p=8040#8040 Forum post by cafamily]]



==Related pages==
- [[MessageFunctionsInfo Message functions]]
- [[CronJobExamples Cron job examples]]
- [[ProcessQueueInfo Process the message queue]]
- [[PhpListConfigSendRate Setting the send speed]]
Deletions:
[[PhplistDocumentation Phplist Documentation]]
=====Title of the page =====
//This page is a **template** intended for documentation of **official phplist features**. This page belongs to CategoryTemplate (which contains more handy templates). To create a phplist **documentation** page, [[http://docs.phplist.com/DocumentationTemplate/clone clone this page]], replace the title with a meaningful one and replace this paragraph with the actual page content.//


Revision [872]

The oldest known version of this page was created on 2006-10-20 20:14:05 by AlStillero [Preparation of the page and one addition]
Page was generated in 0.7324 seconds