13,420
edits
Changes
→Automating Backups (cron)
'''Cron''' is a ''daemon'' (i.e. a program that runs in the background). The term ''"Cron"'' is short for '''Chronograph''' which was an old fashioned term for a '''stop watch''' or '''timer'''. The role of '''Cron''' is to run tasks periodically. It can run tasks for the system (as root) or for a user (including regular users).Every user has a crontab (Cron Table) which is a list of tasks they want to run periodically. You do not edit this file manually: instead, you edit this table using the command '''crontab -e'''. Once you run the command, you will get an empty file where you have to insert a line like this:
<pre>10 * * * * echo "Cron ran this job at: "`date` >> /tmp/cron.log</pre>
This tells cron to run the command '''echo "Cron ran this job at: "`date` > /tmp/cron.log''' at the 10th minute of every hour of every day of every month.
'''Perform the following steps:'''
# Refer to the following WIKI to learn how to use cron: [[crontab tutorial]]# In your host machine as root, edit your crontab and enter the line above. Modify the setting so it will run that echo command every 2 minutesminute by creating a crontab (via '''crontab -e''') entry with the following line:<br><source>10 * * * * echo "Cron ran this job at: "`date` >> /tmp/cron.log</source># Save and exit your crontab edit session.# Wait for two minutes one minute to pass, and check the '''/tmp/cron.log''' file to see if it was created with the expected contents.<br>(You can also check '''/var/log/cron''' file to see what jobs were run).# Perform a Net-search to see how to configure that crontab entry to run every two minutes instead of every minute.# Edit your crontab entry to run same command every two minutes, save and exit, and then confirm by viewing '''/tmp/cron.log''' and '''/var/log/cron''' files.# Perform a Net-search to see how to run a cron for a command for every hour.
# Edit your crontab to '''make automatic backups using the rsync command''' of the '''/etc''' directory from '''vm1''', '''vm2''', and '''vm3''' into '''/backup/vm1''', '''/backup/vm2''', and '''/backup/vm3''' every hour and overwrite the previous backup.