Backup with CRON

Below is the code added to to back up all the files in the /var/www/marketing/ directory,. It is set to run every day at 1am and saves a zip file with the current date into the /backup directory:

* 1 * * * cd /backup && zip -r "$(date +"%Y%m%d")" /var/www/marketing/

This command has been added using crontab -e (vim commands needed here).

After making changes, be sure to run this to restart cron:

service crond restart

The command below can show you what jobs are currently running:

crontab -l

The command below will delete all cron jobs:

crontab -r

Leave a Reply