Correct way of setting up CRON job in dockertemplate file command line


I am trying to add two cron job tasks to my dockerfile. If I add one (1 line) everything works. If I want to add more I sometimes encounter problems. What is the correct way to add multiple cron jobs with balena when deploying? One should check every 5 minutes, the other one run once a day at 2:00 am.


RUN (crontab -l ; echo “*/5 * * * * /usr/src/app/”) | sort - | uniq - | crontab -
RUN (crontab -l ; echo “0 2 * * * /usr/src/app/”) | sort - | uniq - | crontab -

Hi @rquant, I personally would do it with a script, like this one in balenaDash:

I’m wondering if when you’re adding two there’s some kind of race condition happening that’s avoided by using a script; the above has always worked reliably in my experience.

1 Like

Thank you, I will try it!