Closed mittma closed 1 year ago
I found a possibility by bind mounting a script named 09-add-cron-jobs.sh into /etc/cont.init.d, which adds the missing cron entries to the file /var/spool/cron/crontab/librenms. See also https://community.librenms.org/t/docker-container-install-scheduler-not-running-and-servername/21835
brm
Description
I was looking for a possibility to schedule jobs within the librenms container (smokeping:generate and snmp-scan), but failed. The usual way would be to use "crontab -u librenms -e" within the container, which edits the file /var/spool/cron/crontabs/librenms. To make changes persistent, it is possible to bind mount this file from a host file into the container. But in /etc/cont.init.d/07-svc-cron.sh the complete directory /var/spool/cron/crontab gets deleted and recreated so a bind mounted file is lost. Using a file root (and doing "sudo -u librenms ..." within) also does not work, since the complete directory gets wiped. I currently have to schedule the jobs on the host and use "docker exec -u librenms librenms sh -c '...'" to call the scripts and programs within the container (which fails when the container is not running).
Is there a possibility to allow customization of job scheduling within 07-svc-cron.sh?
Idea 1: echo environment variable(s) to cron file, like
echo -e "${LIBRENMS_ADD_CRON}" >>${CRONTAB_PATH}/librenms
and ${LIBRENMS_ADD_CRON} has the content of "0 /2 command1\n0 1 * command2" (echo -e and newline are used for several entries - not beautiful, but works)Idea 2: Copy files from a (new) directory /data/crontabs (where /data is bind mounted to the host) to /var/spool/cron/crontabs and add the entries of 07-svc-cron.sh to an eventually existing file librenms (otherwise create a new file)
I hope my ideas have been of any help.
Best regards, Martin.