Thanks for asking question!
For Custom Containers you may follow below steps.
- Enable CRON job for custom containers:
- To Enable cron, add the following line to Dockerfile: RUN apt-get install -yqq cron
- And following line in the container init script (init_container.sh)
(crontab -l && echo "* * * * * echo 'hello from cron' >> /home/site/wwwroot/cron1.txt")|crontab - In this case we will write “hello from cron” to file /home/site/wwwroot/cron1.txt every minute. You can replace this with anything else you wish to run periodically.
- echo 'hello from cron' >> /home/site/wwwroot/cron1.txt
- for crontab syntax please refer to:
- List item
https://www.adminschoice.com/crontab-quick-reference
https://crontab-generator.org/
•For Blessed Images:
- Create a script file in /home directory of the App Service and trigger it via the startup command under Configuration blade.
- A test script which installs cron as well as create a CRON job:
!/bin/sh
apt-get update -qq && apt-get install cron -yqq
service cron start
mkdir /home/BackupLogs
(crontab -l 2>/dev/null; echo "*/5 * * * * cp /home/LogFiles/*.log /home/BackupLogs")|crontab
Hope this helps!