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