Cron or Schedule Job on webapp with linux container

Mohit Kumar Sharma 86 Reputation points


I am using docker custom container to run schedule the cron job.
I installed the cron
RUN apt-get update \
&& apt-get install -y \

And schedule it like

Setup the crontab.

ADD ./docker/crontab /etc/cron.d/portal-cron
RUN chmod 0644 /etc/cron.d/portal-cron
RUN crontab /etc/cron.d/portal-cron

Everything is working fine. All scheduled cron is working fine.

Now jump the query. There is a cron that takes approx 1 hour to complete. It starts at 9 am daily and is completed at 10 am. In the meantime I need to deploy some code changes. For this I created a new docker image with new changes, now I need to deploy it. Now the time is 9:30 in the morning. This cron has already done half the work and still has half the work left. If I deploy new containers or new changes. Will this stop the execution on this crom? If yes, it can create an issue for me. How can i manage this scenario?

This cron job is a PHP file which is using other php file.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,021 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ryan Hill 26,241 Reputation points Microsoft Employee

    Hi @Mohit Kumar Sharma , to answer you question,

    Will this stop the execution on this cron?

    , the answer is yes it can. There are two scenarios. One is anytime you restart your app, the platform checks to see if it's using the latest image. If not, the image is pulled and the app is started. If you're using continuous deployment, the platform will trigger the webhook to restart the web app, thereby resulting in checking for the latest image. So yes, it can create an issue for you if you trigger this update during the run of your job.

    To better manage this scenario, use more static tagging of your images; say like using a version number instead of commonly used words like :prod or :latest. Instead push new images with more controlled tags like a version number. That way, you can control when to use the newer image.


    0 comments No comments

0 additional answers

Sort by: Most helpful