Luc Shelton

CRON Jobs with Alpine Linux and Docker

CRON Jobs with Alpine Linux and Docker

CRON Jobs with Alpine Linux and Docker

CRON Jobs with Alpine Linux and Docker

Updated 3 years ago
2 Minute(s) to read
Posted 3 years ago Updated 3 years ago 2 Minute(s) to read 15 comments

I recently added some CRON job scripts as part of my Docker container image so that SilverStripe tasks could be executed on a regular basis. Unfortunately when I first configured the CRON daemon to run the scripts, I noticed that they were never being executed at the configured interval (found in crontab -l). The reason for this is because the CRON daemon is never launched when the Docker container is booted up for the first time. In part this is because there isn't an "init system" that is included as part of the Docker image for Alpine Linux, and additionally it does not come with the "init scripts" (configuration files for starting processes) for the CRON daemon (crond).

If you're looking to run automated CRON jobs from your Alpine Docker container, you are going to want to do the following.


Install System Packages

Make sure to install the following packages.

apk add busybox-initscripts openrc --no-cache

Or include it as part of your Dockerfile.

RUN apk add busybox-initscripts openrc --no-cache

This should ensure that the init system starts on boot, alone with the crond process.


Tweak CRON Configuration

Ensure that your CRON configuration looks like this if you are intending on using the run-parts tool. This is modifiable from the /etc/crontabs/root file, if you are running as the root user (I don't recommend that you do).

*/1 * * * * run-parts /etc/periodic/1min

Additionally, ensure that any scripts that are stored under directories such as /etc/periodic/15min and /etc/periodic/1min DO NOT specify the .sh file extension, as the script will not be executed if they are.

Finally, ensure that the script itself has the relevant permissions.

chmod -R a+x /etc/periodic/1min

If you want to test the scripts that are placed under the path /etc/periodic/1min, run the following command.

run-parts --test /etc/periodic/1min

Start the CRON Daemon

Run the following command to ensure that the CRON daemon starts as part of the daemon.

rc-service crond start && rc-update add crond

And now it should be running as expected.



Comments

Comments

You explained that perfectly.
<a href="https://ouressays.com/">parts of a research proposal</a> research paper services <a href="https://researchpaperwriterservices.com/">research paper help</a> thesis proposal
<a href=https://topswritingservices.com/>customer service essay</a> writing an argumentative essay <a href=https://essaywriting4you.com/>best essay writing service reddit</a> pro essay writing service
dos and don ts of college essays https://service-essay.com


Wonderful postings. Cheers.
<a href="https://domyhomeworkformecheap.com/">do my math homework for me</a> cpm homework <a href="https://domycollegehomeworkforme.com/">do my math homework</a> pay to do my homework


Thanks! A good amount of facts!
<a href="https://helpwithdissertationwriting.com/">dissertation writing</a> custom dissertation writing services <a href="https://dissertationwritingtops.com/">phd dissertation</a> phd thesis

You actually stated that really well.
<a href="https://helpwithdissertationwriting.com/">writing help</a> dissertation help <a href="https://dissertationwritingtops.com/">dissertation writing service</a> phd thesis


Many thanks, A lot of posts!
<a href="https://studentessaywriting.com/">custom essay writing</a> write my essay service <a href="https://essaywritingserviceahrefs.com/">best essay writing service australia</a> essay writing help


Nicely put. Regards!
<a href="https://homeworkcourseworkhelps.com/">can you do my homework</a> do my finance homework <a href="https://helpmedomyxyzhomework.com/">pay to do my homework</a> pay to do my homework
<a href=https://essaytyperhelp.com/>essays help</a> cheap essay help <a href=https://helptowriteanessay.com/>college application essay help</a> medical school personal statement
how to write short essay https://essayssolution.com


Regards. An abundance of knowledge!
<a href="https://helpwithdissertationwriting.com/">dissertation definition</a> dissertations online <a href="https://dissertationwritingtops.com/">dissertation def</a> define dissertation


Kudos. I appreciate it.
<a href="https://service-essay.com/">graduate paper writing service</a> paper writing service reviews <a href="https://custompaperwritingservices.com/">pay someone to write your paper</a> order custom paper
<a href=https://payforanessaysonline.com/>pay to write paper</a> buy essay papers <a href=https://buycheapessaysonline.com/>buy an essay</a> pay for papers
essays website https://paperwritingservicecheap.com


You've made your point.
<a href="https://helpwithdissertationwriting.com/">dissertation writing services</a> dissertation abstract <a href="https://dissertationwritingtops.com/">dissertation abstract</a> phd thesis


Whoa all kinds of awesome info!
<a href="https://essayssolution.com/">write my research paper for me</a> professional essay writers <a href="https://cheapessaywriteronlineservices.com/">writing a persuasive essay</a> what should i write my college essay about
<a href=https://essayssolution.com/>write a essay</a> writing a personal essay <a href=https://cheapessaywriteronlineservices.com/>persuasive essay writer</a> essay writer website
best resume writing services nyc https://writingresearchtermpaperservice.com