Monday, May 08, 2006

PB's contrib - making processqueue cron work

Did the following to set the cron to work for phplist processqueue...

To check the error messages in cron piped the message to log.txt
31 17 * * * /home/apachemails/phplist -pprocessqueue > log.txt

Got the following message:
[apachemails@krishna ~]$ cat log.txt
PHPlist version 2.10.2 (c) 2000-2006 Tincan Ltd, http://www.phplist.com

Error: USER environment variable is not defined, cannot do access check.
Please make sure USER is defined.

>From google got the following solution:
http://www.tequilafish.com/2005/11/17/phplist-with-crontab-user-environment-variable-is-not-defined/

This happens because when a crontab executes, the *$USER* variable is not
set. We must set it in our script. So open up the phplist file and add the
following:
USER=youusername
export USER

The entire file should now look like this:
CONFIG=/path/to/phplist/config/config.php
export CONFIG

USER=yourusername
export USER

/path/to/php /home/yourusername/path/to/phplist/admin/index.php $*

Note that you also must set the *$commandline_users* variable in your *
config/config.php*:
$commandline_users = array("yourusername");

With all of that in place, you can automate your queue and bounce processing
with a crontab like this (adjust your paths accordingly):
# Suppress crontab emails
MAILTO=""

# Process phplist queue daily, every half hour
0,30 * * * * /home/yourusername/phplist -pprocessqueue

# Process phplist bounces once a day, 5am
0 5 * * * /home/yourusername/phplist -pprocessbounces
In our case:
USER=apachemails
export USER

now the cron works fine :)

No comments:

Post a Comment