To add a cron job and make it accessible in the shell, you first need to configure your environment to point to the libraries.

Step 1: Add the zf script to the /usr/bin/ directory ( and zf.php)
These files are available in the bin directory of the ZendFramework 1.x library. You can either copy them or create a symbolic link.

Step 2: Configure your bash to recognize the zf alias.
Edit the ~/.bashrc file and insert the following line

alias zf="/usr/bin/"

Step 3: Add the global variable ZEND_TOOL_INCLUDE_PATH to your bash. This will allow the script to find the zend library
Edit the ~/.bashrc file and insert the following line


Step 4: Create the skeleton for your CLI task.
Here is how I implement them. Of course, you are free to place your file wherever you like! Zend is flexible enough to be configured/adapted in different ways.
In this example, we have set up a library dedicated to our project called foo, and placed all our CLI files in a directory called "Cronjobs".
Therefore, our file will need to be placed in the directory: /var/www/myProject/library/Foo/Cronjobs/MytaskProvider.php
Our task will be called "Mytask" and its action will be "do".

class Foo_Cronjobs_MytaskProvider extends Zend_Tool_Framework_Provider_Abstract
public function DoitCronjobs()
echo "Hello World !";

All public functions will then be available as separate tasks.

Step 5: Register your task so that it is accessible from the list of Zend commands.
Edit the ~/.zf.ini file and insert the following line

php.include_path = "/var/www/monProjet/library/:.:/usr/share/php:/usr/share/pear"
basicloader.classes.21 = "Foo_Cronjobs_MytaskProvider"

To add a new task, simply increment the class (here 21, so move to 22... and so on).