Crontab with flask command on Azure App Service with Linux ASP

Issue

What I’m trying to do is to run flask command in crontab on Azure App Service with linux App Service Plan.

So far I have my startup.sh to setup cron but the command does not execute, nothing in the logs.

# startup.sh

#!/bin/sh
apt-get update -qq
apt-get install gcc -yqq
apt-get install g++ -yqq
source antenv/bin/activate
pip install -r requirements.txt
apt-get install cron -yqq
service cron start
(crontab -l 2>/dev/null; echo "*/5 * * * * /home/site/wwwroot/antenv/bin/python -m flask db update_migrations")|crontab
gunicorn --bind=0.0.0.0 --workers=4 startup:app

When I was trying to execute the command via SSH I had to install requirements and then, the command itself was working

> /home/site/wwwroot/antenv/bin/python -m flask db update_migrations

but in the crontab it does not want to.

How to debug it, where to find the problem.

Thank you for your help!

Solution

It’s more of a workaround but maybe you can leverage Advanced Python Scheduler which has also Flask integration. This way you can bypass problems with cron.

Answered By – Iwona Grabska-GradziƄska

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published