How do I setup crons / the crontab for my eZ Publish site?

Crontab icon

In order to setup a cron job please go to your domain overview and follow the "Crontab" link.

new cronjob

Now select your users crontab file and click "Schedule a Task"

Now you can configure your cronjob by defining when and what should be run. For eZ Publish it is common to execute your script like this.

PATH and LD_LIBRARY_PATH are needed since php doesn`t know automaticly where the php extensions are.

export PATH=/usr/local/zend/bin:$PATH && export LD_LIBRARY_PATH=/usr/local/zend/lib:$LD_LIBRARY_PATH && cd ~/httpdocs && php runcronjobs.php frequent

"frequent" defines the group of scripts you are using defined in your cronjob.ini.append.php file.

"~/httpdocs" is the path to your eZ Publish root. You can figure out the location of your eZ Publish root by typing

cd ~ && cd httpdocs && pwd

Please beware the a improper setup of the crons may harm the overall server performance. Handle this issue with great care.

Crontab setup
Preferences

You have finally completed setting up one specific cronjob. If you want to monitor your cron output enter your email address in the preferences.

Cron job done

Hints:

if you need to write the output of your cron files to a log file use this command.

export PATH=/usr/local/zend/bin:$PATH && export LD_LIBRARY_PATH=/usr/local/zend/lib:$LD_LIBRARY_PATH && cd ~/httpdocs && php runcronjobs.php frequent >> var/log/cron.log 2>&1

Sample cronjob.ini.append.php

<?php /* #?ini charset="utf-8"?

[CronjobPart-frequent]
Scripts[]
Scripts[]=notification.php
Scripts[]=workflow.php
Scripts[]=hide.php
Scripts[]=indexcontent.php
Scripts[]=ezflowupdate.php

[CronjobPart-hourly]
Scripts[]
Scripts[]=unpublish.php
Scripts[]=runmonitor.php

[CronjobPart-daily]
Scripts[]
Scripts[]=ezfoptimizeindex.php
Scripts[]=ezflowcleanup.php
Scripts[]=runpatch.php
Scripts[]=syncnetwork.php

[CronjobPart-weekly]
Scripts[]
Scripts[]=basket_cleanup.php
Scripts[]=linkcheck.php
Scripts[]=unlock.php
Scripts[]=subtreeexpirycleanup.php
Scripts[]=internal_drafts_cleanup.php
Scripts[]=session_gc.php

[CronjobPart-monthly]
Scripts[]
Scripts[]=old_drafts_cleanup.php
*/ ?>

Sample crontab file

Just needed for reference.

# Do not edit with crontab -e, use file instead "crontab settings/override/crontab.txt"
#  -- Sitename -- crontab setup --

0-55/5 * * * * cd ~/httpdocs && /usr/bin/php -d memory_limit=512M runcronjobs.php frequent >/dev/null 2>&1
35 * * * * cd ~/httpdocs && /usr/bin/php -d memory_limit=512M runcronjobs.php hourly >/dev/null 2>&1
15 5 * * * cd ~/httpdocs && /usr/bin/php -d memory_limit=512M runcronjobs.php daily >/dev/null 2>&1
15 6 * * 1 cd ~/httpdocs && /usr/bin/php -d memory_limit=512M runcronjobs.php weekly >/dev/null 2>&1
15 4 2 * * cd ~/httpdocs && /usr/bin/php -d memory_limit=512M runcronjobs.php monthly >/dev/null 2>&1
15 5 * * 1 cd ~/httpdocs && /usr/bin/php -d memory_limit=512M bin/php/ezcache.php -clear-all --purge >/dev/null 2>&1