diff --git a/docker/root/custom-cont-init.d/defaults b/docker/root/custom-cont-init.d/defaults index e07ed6a8..cfbc0776 100644 --- a/docker/root/custom-cont-init.d/defaults +++ b/docker/root/custom-cont-init.d/defaults @@ -21,6 +21,9 @@ echo "Starting ytdl-sub..." chown -R ${PUID:-abc}:${PGID:-abc} \ /config +# always create empty cron log file on start +echo "" > "$LOGS_TO_STDOUT" + # set up cron if [ "$CRON_SCHEDULE" != "" ] ; then [[ ! -e "$CRON_SCRIPT" ]] && \ @@ -51,19 +54,15 @@ if [ "$CRON_SCHEDULE" != "" ] ; then echo "Cron enabled with schedule $CRON_SCHEDULE_CLEAN" if [ "$CRON_RUN_ON_START" = true ] ; then - echo "Running cron script on start" - . "$CRON_WRAPPER_SCRIPT" + echo "Running cron script on start in the background" + # ensure it runs as abc to respect puid/guid with delay for tail to start + su -s "/bin/bash" -c "sleep 5 && . '$CRON_WRAPPER_SCRIPT'" abc > /dev/null 2>&1 & fi else echo "Error in CRON_SCHEDULE definition, disabling cron." exit 1 fi else - echo "CRON_SCHEDULE not specified, disabling cron." - echo "# min hour day month weekday command" > /config/crontabs/abc - echo "" >> /config/crontabs/abc + echo "CRON_SCHEDULE not specified, leaving crontabs as-is. Current configuration in /config/crontabs/abc" + cat /config/crontabs/abc fi - -# always create cron log file, after cron runs -# on start to not tail it again -echo "" > "$LOGS_TO_STDOUT"