3

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!

piotr.gradzinski
  • 873
  • 1
  • 10
  • 22

2 Answers2

1

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.

0

Are you sure your startup.sh is executable?

The script must be executable, so either install w/ unix and chmod 755 start.sh or use a git command (see How to add chmod permissions to file in Git?).

Also see https://stackoverflow.com/a/69923647/2606766 for a detailed description and potential pitfalls.

HeyMan
  • 1,529
  • 18
  • 32