Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Add cron job to a docker container

Featured Replies

How can one add a cron job to a docker container in particular the mariadb container.

I would like to be able to backup the xbmc databases in case of something, most of it I care for the watched status.

 

Thank you.

  • Author

Thanks for the tip.

I managed to add cron to needo's image like this:

 

Dockerfile:

FROM needo/mariadb:latest
MAINTAINER soana <[email protected]>
ENV DEBIAN_FRONTEND noninteractive

# Add our crontab file
ADD crontab.txt /config/crontab.txt
ADD cronjob /config/cronjob

#Use the crontab file
RUN crontab /config/crontab.txt

# Start cron
RUN cron

VOLUME /backup

 

cronjob file:

#!/bin/bash
##backup databases
mysqldump -u root MyMusic46 > /backup/MyMusic_$(date +%Y-%m-%d).sql
mysqldump -u root MyVideos78 > /backup/MyVideos_$(date +%Y-%m-%d).sql

##Delete files "My*" older than 5 days
find /backup/My* -mtime +4 -exec rm {} \;

Reminder don't forget to chmod +x this file before building the image

 

crontab.txt

00 3 * * * /config/cronjob

 

 

Now I'm looking into a way to be able to edit the crontab.txt and cronjob files while the container is running eliminating the need to rebuild the image every time one of these files have to change.

I'm sure someone will come up with a much more elegant solution eventually but until then I have my sql backups and I'm happy with my Linux noob solution.

 

 

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.