Tar is quite useful for copying directory trees, and is much more powerful than cp. To copy directory /home/myhome/myimportantfiles to /share/myhome/myimportantfiles:
cd /home/myhome/myimportantfiles
tar -cvf - . | tar -C /share/myhome/myimportantfiles/ -xv
To schedule this to happen every day at 1am:
crontab -e
vi will run. If you are unfamiliar with vi, push ‘i’ to insert, and enter:
0 1 * * 0-6 cd /home/myhome/myimportantfiles;tar -cvf - * | tar -C /share/myhome/myimportantfiles/ -xv
push ‘escape’, ‘:’, ‘wq’ (or ‘escape’, ‘ZZ’) to save your crontab entry.
Verify your new job with crontab -l:
$ crontab -l # DO NOT EDIT THIS FILE - edit the master and reinstall. # (/tmp/crontab.17295 installed on Thu May 3 07:58:27 2001) # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $) 0 1 * * 0-6 cd /home/myhome/myimportantfiles;tar -cvf - * | tar -C /share/myhome/myimportantfiles/ -xv
If you want to edit the job by hand, the file is located under your username in /var/spool/cron.