Are cron jobs possible without PHP (CLI) access?

Solutions for other advanced phplisters

Are cron jobs possible without PHP (CLI) access?

Postby thayerw » 7:59pm, Mon 27 Nov, 2006

I've been digging through the forums for 2 days now, reading old threads that traverse a 2-year period. I'm looking for one definitive answer:

Has anyone managed to create a cron job that automates the queue without having access to php in CLI mode?

I'm running phplist 2.10.3 and php 4.4.4-6 with the CGI/FastCGI SAPIs. I cannot run cli mode.

I don't need anything fancy, I would simply like to process the queue automatically every 6 hours or so.

Thanks
thayerw
phpLister
 
Posts: 9
Joined: 5:26pm, Fri 17 Nov, 2006

Postby H2B2 » 8:27pm, Mon 27 Nov, 2006

H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby thayerw » 10:37pm, Mon 27 Nov, 2006

Thanks H2B2, I don't know how I missed the PhpInterfacesInfo page, but that definitely had some useful info on it.

As with most of the other posts regarding cron jobs, it's still a work in progress and so far not working yet--even with the information from the link above.
thayerw
phpLister
 
Posts: 9
Joined: 5:26pm, Fri 17 Nov, 2006

Postby H2B2 » 11:42pm, Mon 27 Nov, 2006

You could run some tests (with a test list) from the command line to check which command works for you, e.g.: a direct call to PHP, or using wget, get, lynx or perhaps curl.

After you determined wich command works, you can schedule it in a crontab file.

You could also take a look at this thread: http://forums.phplist.com/viewtopic.php?t=7191
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby thayerw » 3:52am, Wed 29 Nov, 2006

Thanks again... wget did the trick and the cron job is working great.

Now if only I can get those bounces working.....
thayerw
phpLister
 
Posts: 9
Joined: 5:26pm, Fri 17 Nov, 2006

Postby TdonJohnson » 8:42pm, Fri 01 Dec, 2006

I, too, went through all of the posted cron examples with no success. As far as cron is concerned, my host is running PHP as a CGI.

The standard example below doesn't work for me because the login info doesn't get passed to the script:

/bin/usr/php /home/domain.com/lists/admin/index.php page=processqueue login=myusername password=mypassword >/dev/null

The other examples don't work for me, either, because lynx, wget, and curl are all disabled.

What finally worked for me was to set up a curl call in a php script as follows:

function process_queue() {
//variables
$domain = "http://www.example.com/lists/";
$post_data["page"] = "processqueue";
$post_data["login"] = "PHPLIST_LOGIN";
$post_data["password"] = "PHPLIST_PASSWORD";
$url = $domain . "admin/index.php";

//open connection
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);

//clean up
curl_close($ch);

return $result;
}


$result = process_queue();


Then I use cron to call this script (saved in a PHP file named "phplist_cron.php" in my home directory) as follows (it runs every 15 minutes this way):

*/15 * * * * php phplist_cron.php

Of course, this solution will require a little adjustment (folder names, etc) to work on other servers but it's the only thing that's worked for me!

BTW, I'm running phpList 2.10.3
TdonJohnson
phpLister
 
Posts: 6
Joined: 8:27pm, Fri 01 Dec, 2006

Postby H2B2 » 9:09pm, Fri 01 Dec, 2006

Nice solution TdonJohnson, and thanks for sharing.

Could you add some info on the number of messages you send, and on your (config.php) settings for:
- mailqueue_batch_size
- mailqueue_period
- mailqueue_throttle

Thanks!
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby TdonJohnson » 9:17pm, Fri 01 Dec, 2006

Al, sure thing ...

My host only allows 200 e-mails per hour, so I cap phpList at roughly 150 per hour with the following batch (cron processes the queue every 15 minutes)

define("MAILQUEUE_BATCH_SIZE",38);
define("MAILQUEUE_BATCH_PERIOD",900);
define('MAILQUEUE_THROTTLE',6);

I may readjust these to send a single batch of 150 message once per hour, but have to test it first to make sure the script does not exceed time limits when doing so. Until then, I'll stick with the smaller batches.

cheers,
Don
TdonJohnson
phpLister
 
Posts: 6
Joined: 8:27pm, Fri 01 Dec, 2006

Postby H2B2 » 9:36pm, Fri 01 Dec, 2006

Thanks Don,

I'll include your solution in the docs a soon as I have some time on my hands. I'm sure this will be useful to others.

Cheers,
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby raymon » 6:07am, Sun 24 Dec, 2006

[quote]Al, sure thing ...

My host only allows 200 e-mails per hour, so I cap phpList at roughly 150 per hour with the following batch (cron processes the queue every 15 minutes)

[color=blue]define("MAILQUEUE_BATCH_SIZE",38);
define("MAILQUEUE_BATCH_PERIOD",900);
define('MAILQUEUE_THROTTLE',6);
[/color]
I may readjust these to send a single batch of 150 message once per hour, but have to test it first to make sure the script does not exceed time limits when doing so. Until then, I'll stick with the smaller batches.

cheers,
Don
[/quote]
Thanks for the tip ... I am working on your solution but I have a question:
Why did you have to break the emails dispatched into 4 times an hour? why didn't you simply assign 150 messages for a batch period of 3600. Although you have asked this, I have to ask you again in case you got an answer. In other words, I wonder if the program require such repetitive calls of the processqueue function?

Not sure if I make sense myself :)

Thanks anyway.
raymon
phpLister
 
Posts: 6
Joined: 10:02pm, Sun 07 May, 2006

Postby TdonJohnson » 6:20pm, Tue 26 Dec, 2006

My reason for setting the smaller (and more frequent) batches was that I wasn't sure if sending a larger batch with a slow throttle setting would cause the script to "time out" before it finished a batch.

After sending a few mailings, this hasn't been a problem and I've gradually made the batches larger ... right now the settings are for 150 messages per batch, with one batch per hour.
TdonJohnson
phpLister
 
Posts: 6
Joined: 8:27pm, Fri 01 Dec, 2006

Postby raymon » 6:11am, Fri 29 Dec, 2006

Thanks for your answer,
I guess me too ... it ran without problems although I will have to put the eventlog because I am curious about a couple of things.
raymon
phpLister
 
Posts: 6
Joined: 10:02pm, Sun 07 May, 2006

Postby sing1ejack » 2:09pm, Tue 02 Jan, 2007

I was running into a similar problem to TdonJohnson's - the login information wasn't being passed to the page.  The output indicated that the problem was related to trouble with cookies:

<div>In order to login, you need to enable cookies in your browser</div>

I tried all the recommended options (php, curl, etc), but it was wget that I finally got to work. Turns out that the data got through when I sent it by post instead of get.

wget --post-data "page=processqueue&login=USERNAME&password=PASSWORD" http://your.domain.com/lists/admin/
sing1ejack
PL Nut
 
Posts: 15
Joined: 2:04pm, Wed 22 Nov, 2006

No luck

Postby lizc » 3:10pm, Mon 05 Feb, 2007

Hi

I've tried doing this and get the following message from Cron Daemon

Status: 404
X-Powered-By: PHP/4.4.4
Content-type: text/html

No input file specified.


Any idea why please?

Liz
lizc
phpLister
 
Posts: 7
Joined: 10:43am, Tue 26 Sep, 2006
Location: Spain

Postby JMH » 11:41pm, Fri 16 Feb, 2007

Liz, this is a really simple error. Check your cron setttings very carefully. I have had this happen to me when I mis-typed a pathname. Make sure to use spaces, not ampersands (&) to specify parameters. You also have to type the path as /home/username/public_html/..., not http://www.example.com/...

Hope that helps.
JMH
phpLister
 
Posts: 5
Joined: 11:35am, Wed 07 Feb, 2007

Next

Return to Advanced Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 3 guests

cron