From eea1390491c5c947365802634f925f6016012a59 Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Fri, 6 Oct 2017 10:58:18 +0000 Subject: [PATCH] cron job --- tasks/configure.yml | 1 + tasks/cron.yml | 17 +++++++++++++++++ tasks/main.yml | 2 ++ templates/nextcloud-cron.service | 10 ++++++++++ templates/nextcloud-cron.timer | 10 ++++++++++ 5 files changed, 40 insertions(+) create mode 100644 tasks/cron.yml create mode 100644 templates/nextcloud-cron.service create mode 100644 templates/nextcloud-cron.timer diff --git a/tasks/configure.yml b/tasks/configure.yml index f13af54..3ef31bf 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -5,6 +5,7 @@ with_items: - config:system:set trusted_domains 1 --value={{inventory_hostname}} - maintenance:update:htaccess + - background:cron args: chdir: /var/www/nextcloud become: true diff --git a/tasks/cron.yml b/tasks/cron.yml new file mode 100644 index 0000000..e5caa0b --- /dev/null +++ b/tasks/cron.yml @@ -0,0 +1,17 @@ +--- + +- name: cron service + template: + src: nextcloud-cron.service + dest: /etc/systemd/system/nextcloud-cron.service + +- name: cron timer + template: + src: nextcloud-cron.timer + dest: /etc/systemd/system/nextcloud-cron.timer + +- name: cron timer started and enabled + systemd: + name: nextcloud-cron.timer + state: started + enabled: yes diff --git a/tasks/main.yml b/tasks/main.yml index d2bf05c..e1eb458 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -24,3 +24,5 @@ - include: upgrade.yml - include: apache2.yml + +- include: cron.yml diff --git a/templates/nextcloud-cron.service b/templates/nextcloud-cron.service new file mode 100644 index 0000000..8aa7b4d --- /dev/null +++ b/templates/nextcloud-cron.service @@ -0,0 +1,10 @@ +[Unit] +Description=nextcloud cron job + +[Service] +User=www-data +Group=www-data +ExecStart=/usr/bin/php -f /var/www/nextcloud/cron.php + +[Install] +WantedBy=basic.target diff --git a/templates/nextcloud-cron.timer b/templates/nextcloud-cron.timer new file mode 100644 index 0000000..b39b927 --- /dev/null +++ b/templates/nextcloud-cron.timer @@ -0,0 +1,10 @@ +[Unit] +Description=run nextcloud cron job every 15 minutes + +[Timer] +OnBootSec=5min +OnUnitActiveSec=15min +Unit=nextcloud-cron.service + +[Install] +WantedBy=timers.target