@MJK:
In one thread, Scott indicated that the forthcoming pfSense 1.2 might be needed, because of some very recent tweaks to the CRON features.
- Mike
If you need - can use my code for define cron task pfSense 1.2
// setup cron tasks
// original source from '/etc/inc/pfsense-utils.inc' function 'tdr_install_cron'
// this function safe for other tasks
// *****************************************************************************
// - $task_name: cron task name (for config identification) /for searching my cron tasks/
// - $options: array=[0:minute][1:hour][2:mday][3:month][4:wday][5:who][6:cmd]
// - $task_key: cron command key for searching
// - $on_off: true-'on task', false-'off' task
// required: $task_nameand $on_off
// *****************************************************************************
define('FIELD_TASKNAME', 'task_name');
function ls_setup_cron($task_name, $options, $task_key, $on_off) {
global $config;
update_log("ls_setup_cron: start task_name=$task_name, task_key=$task_key, on_off=$on_off");
// check input params
if(!$task_name) {
update_log("ls_setup_cron: exit - uncomplete input params.");
return;
}
// search cron config settings
if(!$config['cron']['item']) {
update_log("ls_setup_cron: exit - 'config.xml'->[cron]->[items] not found.");
return;
}
// searching task
$x_name='';
$x=0;
foreach($config['cron']['item'] as $item) {
if($item[FIELD_TASKNAME] and $task_name and ($item[FIELD_TASKNAME]==$task_name)) {
update_log("ls_setup_cron: found cron task with name=$task_name on [$x_name].");
$x_name = $x;
}
$x++;
}
unset($x);
// install cron:
// - if not found with such name and not found 'task_key', when install task
// - if found task with such name, when renew this item (delete and add new with all check's)
// deinstall cron:
// - deinstall only, if found such name
switch($on_off) {
case true:
if($task_key) {
// searching task
$x=0;
$x_task='';
foreach($config['cron']['item'] as $item) {
if(strstr($item['command'], $task_key)) {
$x_task = $x;
update_log("ls_setup_cron: found cron task with key=$task_key on [$x].");
}
$x++;
}
unset($x);
if($x_task and (!$x_name or ($x_task != $x_name))) { // other task with $task_key alredy installed
update_log("ls_setup_cron: can't add cron task, while such task exists $task_key");
break;
} else {
if(is_array($options)) {
// delete this item (by name)
if($x_name > 0)
unset($config['cron']['item'][$x_name]);
// and add new
$cron_item = array();
$cron_item[FIELD_TASKNAME] = $task_name;
$cron_item['minute'] = $options[0];
$cron_item['hour'] = $options[1];
$cron_item['mday'] = $options[2];
$cron_item['month'] = $options[3];
$cron_item['wday'] = $options[4];
$cron_item['who'] = $options[5];
$cron_item['command'] = $options[6];
// check options
if(!$cron_item['who']) $cron_item['who'] = "nobody";
$config['cron']['item'][] = $cron_item;
write_config("Installed cron task '$task_name' for 'lightsquid' package");
configure_cron();
// log
update_log("ls_setup_cron: add cron task '$task_name'='" . $cron_item['command'] . "'");
}
}
} else
// log
update_log("ls_setup_cron: input prm 'task_key' not defined");
break;
case false:
// delete cron task only with name $task_name
if($x_name > 0) {
unset($config['cron']['item'][$x_name]);
write_config();
// log
update_log("ls_setup_cron: delete cron task '$task_name'");
}
break;
}
configure_cron();
update_log("ls_setup_cron: end");
}