[DOCKER] Fix various cron issues

This commit is contained in:
Jesse Bannon 2025-04-02 21:08:08 -07:00
parent 6cf41a06b5
commit 4b35530231

View file

@ -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"