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.

Example

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.
<?php
/* HELP

   TableBackups/products.php

   This script makes a copy of products in
   prodBackup.
*/

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

include("../../config.php");
include($FANNIE_ROOT."src/mysql_connect.php");
include($FANNIE_ROOT."src/cron_msg.php");

$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");
else
	echo cron_msg("Successfully backed up products");
?>