Replaced cronie by yacron.

This commit is contained in:
yohan 2020-03-21 17:07:19 +01:00
parent a94ea0fb19
commit 91f1d16f9f
4 changed files with 105 additions and 17 deletions

View File

@ -1,13 +0,0 @@
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m | h | day of month | month | day of week | user | command
3 0 * * * root docker -H tcp://127.0.0.1:2375 exec mysql-server /root/nettoyer_quotas.sh > /proc/1/fd/2 2>&1
3 1 * * * root docker -H tcp://127.0.0.1:2375 exec mysql-server sh -c "mysqldump --databases mysql -uroot -pXXXXXXXX > /mnt/dumps/mysql_dump-mysql_`date +\%d-\%m-\%Y`" > /proc/1/fd/2 2>&1
13 1 * * * root docker -H tcp://127.0.0.1:2375 exec mysql-server sh -c "mysqldump --databases gogs owncloud semanticscuttle -uroot -pXXXXXXXX > /mnt/dumps/mysql_dump_`date +\%d-\%m-\%Y`" > /proc/1/fd/2 2>&1

101
crontab-example.yaml Normal file
View File

@ -0,0 +1,101 @@
jobs:
- name: test-sendmail
command: echo "test sending a mail"
schedule:
minute: "20"
hour: "0"
captureStdout: true
utc: false
onSuccess:
report:
mail:
from: ovh1
to: mail@mail.net
smtpHost: 127.0.0.1
# - name: duplicity-stack
# command: docker -H tcp://127.0.0.1:2375 exec cron-duplicity /root/gen_bootstrap.sh
# schedule:
# minute: "26"
# hour: "4"
# utc: false
# captureStdout: true
# captureStderr: true
- name: mysql-stack-01
command: docker -H tcp://127.0.0.1:2375 exec mysql-server /root/nettoyer_quotas.sh
schedule:
minute: "3"
hour: "0"
utc: false
captureStdout: true
captureStderr: true
onFailure:
report:
mail:
from: ovh1
to: mail@mail.net
smtpHost: 127.0.0.1
- name: mysql-stack-02
command: docker -H tcp://127.0.0.1:2375 exec mysql-server sh -c "mysqldump --databases mysql -uroot -pXXXXXXX > /mnt/dumps/mysql_dump-mysql_`date +\%d-\%m-\%Y`"
schedule:
minute: "3"
hour: "1"
utc: false
captureStdout: true
captureStderr: true
onFailure:
report:
mail:
from: ovh1
to: mail@mail.net
smtpHost: 127.0.0.1
- name: mysql-stack-03
command: docker -H tcp://127.0.0.1:2375 exec mysql-server sh -c "mysqldump --databases gogs owncloud semanticscuttle -uroot -pXXXXXXX > /mnt/dumps/mysql_dump_`date +\%d-\%m-\%Y`"
schedule:
minute: "13"
hour: "1"
utc: false
captureStdout: true
captureStderr: true
onFailure:
report:
mail:
from: ovh1
to: mail@mail.net
smtpHost: 127.0.0.1
- name: reverse-proxy-stack
command: docker -H tcp://127.0.0.1:2375 exec dockerreverseproxystack_reverse-proxy_1 certbot renew
schedule:
minute: "5"
hour: "2"
utc: false
captureStdout: true
captureStderr: true
failsWhen:
producesStderr: false
producesStdout: false
onFailure:
report:
mail:
from: ovh1
to: mail@mail.net
smtpHost: 127.0.0.1
- name: mail-stack
command: docker -H tcp://127.0.0.1:2375 exec dovecot /root/dovecot_expire.sh
schedule:
minute: "30"
hour: "0"
utc: false
captureStdout: true
captureStderr: true
onFailure:
report:
mail:
from: ovh1
to: mail@mail.net
smtpHost: 127.0.0.1

View File

@ -7,4 +7,4 @@ services:
restart: always restart: always
network_mode: "host" network_mode: "host"
volumes: volumes:
- ./crontab:/etc/crontab:Z - ./crontab.yaml:/root/crontab.yaml:Z

View File

@ -10,9 +10,9 @@ then
exit 1 exit 1
fi fi
fi fi
openssl enc -aes-256-cbc -d -in ~/secrets.tar.gz.enc | tar -zxv --strip 2 secrets/docker-cron-global-stack${HOST}${INSTANCE}/crontab openssl enc -aes-256-cbc -d -in ~/secrets.tar.gz.enc | tar -zxv --strip 2 secrets/docker-cron-global-stack${HOST}${INSTANCE}/crontab.yaml
sudo chown root. crontab sudo chown root. crontab.yaml
sudo chmod 644 crontab sudo chmod 644 crontab.yaml
unset VERSION_CRON unset VERSION_CRON
export VERSION_CRON=$(git ls-remote https://git.scimetis.net/yohan/docker-cron.git| head -1 | cut -f 1|cut -c -10) export VERSION_CRON=$(git ls-remote https://git.scimetis.net/yohan/docker-cron.git| head -1 | cut -f 1|cut -c -10)