PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, August 19, 2022

[FIXED] What is the best solution for Cron Schedule environmental variables in a Docker container?

 August 19, 2022     cron, docker, environment-variables, python     No comments   

Issue

I have a Python script that will run on certain intervals as the cron schedule will invoke the Python script inside a Docker container. I want the cron schedule expression to be set through an environment variable, like this:

CRON_SCHEDULE="*/5 * * * *"

So the user can freely choose how often the script will run. On the other hand, I have a hard time making a bash script that will read this environment file and replace the existing crontab using sed as I need to escape any possible character.

That brings me to the point where I'm wondering if there is any better solution for running a Python script on a schedule while also having easy configuration of the running schedule?


Solution

You should use the solution described in this answer https://stackoverflow.com/a/70897876/3669093

Whenever the environment variable is changed the container is restarted and the schedule is updated.

If you need more guidance, shoot your questions.



Answered By - mwalidawadeen
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing