updated as of: March 30, 2015
last author: Andy Theuninck
The latest documentation can be found on the Project Wiki. The information below may be out of date.
N.B. - pretty much all of this only applies if fannie is installed a unix-style system

To facilitate the use of a single configuration file and minimize the number of languages required to run fannie, I'm proposing scripts to run various scheduled tasks be written in PHP when reasonably possible.

To keep scripts portable, the web interface for configuring jobs will start all scripts with a working directory of {FANNIE}/cron/. This is rather vital. Starting each script in a consistent relative path means the script can locate fannie's configuration file without hard-coding any paths.

To make scripts available to the web interface, they must be located in {FANNIE}/cron/. Scripts can be placed in further subdirectories; just keep in mind the inital working directory will always be {FANNIE}/cron/.

If you place a comment block in your script containing the string HELP, this comment will be used as user-facing documentation explaining what the script does that is available by clicking the link in the 'Command' column of the web interface, {FANNIE}/cron/management/index.php .

By default, the web interface will direct script output to {FANNIE}/logs/dayend.log.


Here's a sample script to backup the products table. For the sake of the example, consider the file to be {FANNIE}/cron/TableBackups/products.php. The function cron_msg() simply appends a timestamp and filename to the given string for better logging.


   This script makes a copy of products in

chdir("TableBackups"); // because of inital working directory


$result1 = $dbc->query("TRUNCATE TABLE prodBackup");
$result2 = $dbc->query("INSERT INTO prodBackup SELECT * FROM products");

if ($result1 === false || $result2 === false)
	echo cron_msg("Error backing up table: products");
	echo cron_msg("Successfully backed up products");