Skip to content

Instantly share code, notes, and snippets.

@erangaeb
Last active March 30, 2016 14:22
Show Gist options
  • Save erangaeb/254a8dcbfcbc53f11fde to your computer and use it in GitHub Desktop.
Save erangaeb/254a8dcbfcbc53f11fde to your computer and use it in GitHub Desktop.
Rsync with cron job
# edit crontab file
crontab -e
# rsync as a cron job
30 23 * * * flock -n /tmp/rsync.lock -c "rsync -avzh [email protected]:/home/pagero/storage/ /home/eranga/storage/>/tmp/rsync.log"
# things to notice
1. 30 23 : Cron job runs everyday 23:30 PM (11.30 PM)
2. flock -n /tmp/rsync.lock : Will prevents to run duplicate cronjobs(means only one cron job will be running)
3. >/tmp/rsync.log : Will take the output of rsync job to /tmp/rsyn.log file
# list cron jobs
crontab -l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment