Home > front end >  How to configure supervisor not to kill jobs started by cron in docker container
How to configure supervisor not to kill jobs started by cron in docker container

Time:02-05

I wanted to run cron and run a few script started at a time set in crontab. I've installed cron on my docker container and wanted to add some crontab lines and cron starting in separate script. Here are fragments of my configuration

supervisord.conf

[program:cron]
command=/stats/run-crontabs.sh

/stats/run-crontabs.sh

#!/bin/bash

crontab -l | { cat; echo "11 1 * * * /stats/generate-year-rank.sh"; } | crontab -
crontab -l | { cat; echo "12 1 * * * /stats/generate-week-rank.sh"; } | crontab -
cron -f -L 15

and when it is time to run script by cron, I can see only that error in container logs

2022-01-29 01:12:01,920 INFO reaped unknown pid 691343

I wonder how I can run script by cron on docker container. Do I need supervisor?

EDIT: As @david-maze suggested I've done it like he commented and run cron as container entrypoint and problem is the same

Thank you for your help

CodePudding user response:

Ok, I have to post an answer. I've realized that scripts working well, but it saved reports in system root directory, not on directories that I wanted.

It were because of lack of environment variables More you can read those topic, Where can I set environment variables that crontab will use?

but I've resolved my problem with adding that line at the start of 'run-crontabs.sh' script

crontab -l | { cat; echo "$(env)"; } | crontab -
  •  Tags:  
  • Related