commit c90f49ee700732af5f56d1d9980dd18a456d09a3 Author: Alexandre CATTEAU Date: Sun May 22 11:45:24 2022 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..99a3140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +variables.conf +.disabled diff --git a/README.md b/README.md new file mode 100644 index 0000000..fc8e133 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# Nextcloud's cron job timer + +This repository contains Systemd service and timer basic units to run Nextcloud's own cron job regularly (as recommended in the +[official documentation](https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/background_jobs_configuration.html#systemd)). + +### Files +* `cloud-cron.service` is the service file executing Nextcloud's PHP cron job +* `cloud-cron.timer` is the timer starting the service every 5 minutes +#### Installation +* `install.sh` script copies Systemd units to their destination, and enables timer. + +### TODO +* RAS diff --git a/cloud-cron.service b/cloud-cron.service new file mode 100644 index 0000000..79f01dc --- /dev/null +++ b/cloud-cron.service @@ -0,0 +1,6 @@ +[Unit] +Description=Nextcloud cron.php job + +[Service] +User=www-data +ExecStart=/usr/bin/php -f /var/www/nextcloud/cron.php diff --git a/cloud-cron.timer b/cloud-cron.timer new file mode 100644 index 0000000..6f01507 --- /dev/null +++ b/cloud-cron.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Run Nextcloud cron.php every 5 minutes + +[Timer] +OnBootSec=5min +OnUnitActiveSec=5min + +[Install] +WantedBy=timers.target diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..75a9d62 --- /dev/null +++ b/install.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +run_directory=$(dirname "$0") + +if [ -f $run_directory/.disabled ]; then + echo "Installation is disabled. Exiting..." + exit 0 +fi + +echo "Copying Systemd units to system directory..." +sudo cp $run_directory/cloud-cron.service $run_directory/cloud-cron.timer /etc/systemd/system/ + +echo "Reloading Systemd..." +sudo systemctl daemon-reload +echo "Enabling timer (not starting it, either do it manually or reboot)..." +sudo systemctl enable cloud-cron.timer + +echo "Finished install. Exiting..." +exit 0