From 990ee018d24c7a1a705cc45192da9f4e235a8010 Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Thu, 6 Dec 2018 17:32:05 -0600 Subject: [PATCH] SIGTERM now stops crond This means `docker stop` will be faster --- scripts/entrypoint.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index bc158e1..1fe592c 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -27,4 +27,16 @@ echo "$containerId" > /tmp/containerId echo "*/$NEXTCLOUD_CRON_MINUTE_INTERVAL * * * * /cron-tasks.sh $containerId" \ > /var/spool/cron/crontabs/root -exec crond -f -l 0 -L /dev/stdout +# Watch for SIGTERM (someone stops the docker container) so we can tell crond to exit +_term() { + echo "Caught SIGTERM signal!" + kill -TERM "$child" 2>/dev/null +} + +trap _term SIGTERM + +exec crond -f -l 0 & +echo "Started crond" + +child=$! +wait "$child"