Difference between revisions of "Automating your backups with cron"

From docwiki
Jump to: navigation, search
Line 6: Line 6:
 
== User and System Crontab ==
 
== User and System Crontab ==
   
cron has a text based configuration file that contains the commands that should be run and when they should be run. You can view this with
+
cron has a text based configuration file that contains the commands that should be run and when they should be run. There is a '''system crontab''' for all users and each '''user''' has his/her own crontab:
  +
  +
You can view this with
   
 
<pre>
 
<pre>

Revision as of 12:37, 29 October 2020

Motivation

If you only do your backup when you hear about a case of someone loosing data then you will not have a recent backup when you need it. So you should automate the backup process. If you want to run a certain command at a regular interval then you can use the unix cron tool.

User and System Crontab

cron has a text based configuration file that contains the commands that should be run and when they should be run. There is a system crontab for all users and each user has his/her own crontab:

You can view this with
crontab -l

And edit it with:

crontab -e

which opens up your default editor. You can set a different editor with


export EDITOR=/usr/bin/yourfavoriteeditor


Example Crontab