From 6044c359a2a298179785fcd7f79bc6ae984edf44 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Sun, 24 May 2020 03:03:04 -0600 Subject: [PATCH] --- 6.0-Scheduling-via-cron.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 6.0-Scheduling-via-cron.md diff --git a/6.0-Scheduling-via-cron.md b/6.0-Scheduling-via-cron.md new file mode 100644 index 0000000..3feaa76 --- /dev/null +++ b/6.0-Scheduling-via-cron.md @@ -0,0 +1,24 @@ +# scheduling - using cron + +After running this script at least once manually to test your settings, you should schedule it to run automatically so things stay backed up. This is easiest with a simple cron job. + +1. Open root's crontab + + ```bash + sudo crontab -e + ``` + +2. Add your script command line and set the time for execution. I'm assuming your script is located at '/scripts/backup’, all files are at their default locations, you are using the 503-page functionality with default files, and you want to run your backup at 1:07am daily. + + ```ini + 7 1 * * * /scripts/backup/backup.sh -l /var/log/mailcowbackup.log -5 > /dev/null 2>&1 + ``` + + The part after the script command (the '>' and stuff after it) means redirect all output to *null*. This is good so that errors don't junk up your system logs and it doesn't log to your console since no one is around to see it. This is standard practice for running things via cron. That's why periodically reviewing your log file is important! + +3. Save the file (yes, accept that weird random-looking filename) and exit. +4. Confirm your changes by listing the root user's crontab: + + ```bash + sudo crontab -l + ```