rbicelli / pfsense-zabbix-template

Zabbix Template for pfSense
Apache License 2.0
244 stars 107 forks source link

Speedtest cron not created #79

Closed GuillaumeHullin closed 3 years ago

GuillaumeHullin commented 3 years ago

the problem I see is that it doesnt register the Cron... This function seems to not work (but I can add the cron manually successfully):

function pfz_speedtest_cron_install($enable=true){
    //Install Cron Job
    $command = "/usr/local/bin/php " . __FILE__ . " speedtest_cron"; 
    install_cron_job($command, $enable, $minute = "*/15", "*", "*", "*", "*", "root", false);
}           

Originally posted by @GuillaumeHullin in https://github.com/rbicelli/pfsense-zabbix-template/issues/78#issuecomment-876654051

GuillaumeHullin commented 3 years ago

Solution:

function pfz_speedtest_cron_install($enable=true){
    // Install Cron Job
    $command = "/usr/local/bin/php " . __FILE__ . " speedtest_cron"; 
    install_cron_job($command, $enable, $minute = "*/15", "*", "*", "*", "*", "root", true);
}

The last argument was the problem... it should be true in order to write the config.

For reference: https://github.com/pfsense/pfsense/blob/102a3c02996b7eaa5ea8329614a890658978abf6/src/etc/inc/services.inc#L3138

rbicelli commented 3 years ago

In 2.4 setting false it doesn't write config but adds the cron job anyway, just for not let survive it at reboot. Maybe in 2.5 the behavior has changed.