forked from elioqoshi/phplist-manual
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathch036_setting-up-your-cron.xhtml
73 lines (73 loc) · 4.28 KB
/
ch036_setting-up-your-cron.xhtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title/></head><body><h1>Setting up your Cron
</h1>
<h2>What is cron
</h2>
<p> Cron is a time based task scheduler on Unix-like operating systems. For more information check the <a title="Explanation of CRON" target="_blank" href="http://en.wikipedia.org/wiki/Cron">Wikipedia page</a>. This chapter will describe how to set this up on Linux. On other Unix systems the set up will be similar.
<br/></p>
<h2>Why set up cron
</h2>
<p>When you set up the cron, two of the most time consuming parts of phpList will become automated. These are processing the queue and processing the bounces. Once you set up the cron, you will not have to do these in your browser, but they will happen automatically. Sending a campaign will become as easy as sending a normal email from your desktop.
</p>
<h2>Caveats
</h2>
<p>The method described in this chapter requires the CLI version of PHP.  This may not be available on all systems. There are some "hacks" to make it work with other versions of PHP, but this is non-intentional functionality and therefore not described here.
<br/></p>
<h2> Step 1: set up commandline
</h2>
<p>The easiest way to set up the cron is to set up a commandline script that will handle all phpList commands. There is an example in the "bin" directory in the phpList archive file.
</p>
<p>Let's call the commandline script "phplist" and edit it with your favourite text editor:
</p>
<pre>$ nano phplist
</pre>
<p>and type (or copy-paste) the content
<br/></p>
<pre>#!/bin/bash
/usr/bin/php /home/website/public_html/lists/admin/index.php -c /home/website/public_html/lists/config/config.php $*</pre>
<p>You will need to change the above content to fit your system:
</p>
<p><strong>#!/bin/bash</strong> -> the shell that you want to use
</p>
<p><strong>/usr/bin/php</strong> -> the path to the PHP-cli commandline interpreter, this can vary per system. Debian based systems (including Ubuntu) should install the "php-cli" package.
</p>
<p><strong>/home/website/public_html/lists/admin/index.php</strong> -> the path to your phpList installation, pointing to the index.php file in the admin directory of phpList
</p>
<p>
</p>
<p><strong>/home/website/public_html/lists/config/config.php</strong> -> the path to your config file
</p>
<p>Once you have constructed your commandline file, place it somewhere in your path, e.g. in /usr/local/bin and make it executable.
<br/></p>
<pre>chmod 755 /usr/local/bin/phplist</pre>
<p> From then on, you can process phpList on commandline, for example with
</p>
<pre><strong>phplist -pprocessqueue</strong></pre>
<h2>Step 2: set up the crons
</h2>
<p>Once you have the commandline script, you can set up the crons with your favourite cron editor. On Linux, you type "crontab -e" in order to edit your cron entries.
</p>
<pre>0-59/5 * * * * phplist -pprocessqueue > /dev/null 2>&1
0 3 * * * phplist -pprocessbounces > /dev/null 2>&1</pre>
<p>The above example will process the queue once every 5 minutes and process the bounces once a day. That will be sufficient for most systems.
</p>
<p>The example also discards any output, which you will want to do. You can always check the output by running the above commands manually from the shell-prompt.
<br/></p>
<h2>Step 3: tell phpList
</h2>
<p>Once you've set up the cron and it is working, you can tell phpList and some links will disappear. Put the following two lines in your config file:
<br/></p>
<pre>define ("MANUALLY_PROCESS_BOUNCES",0);
define ("MANUALLY_PROCESS_QUEUE",0);</pre>
<p>This will hide the links to process the queue and bounces from the phpList interface.
</p>
<h2>Notes
</h2>
<p>There's no danger in overloading your server. When a second queue processing command is activated when the previous one is still active, phpList will detect this and bail out. Therefore there will always be one active queue sending process at any time. This is also important to ensure that the sending limits, set with Batch processing, will be honoured.
</p>
<h2>Feedback
</h2>
<p>Discuss this chapter <a href="https://discuss.phplist.org/t/setting-up-your-cron-manual-chapter-feedback-and-discussion/226">here</a>.
</p></body></html>