Asif Bacchus 2020-05-24 03:03:04 -06:00
parent 64156655a2
commit 6044c359a2
1 changed files with 24 additions and 0 deletions

@ -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
```