Koozali.org: home of the SME Server

Just a little help setting up a Cron task

Cyrus Bharda

Just a little help setting up a Cron task
« on: September 04, 2002, 11:05:23 AM »
I just would like some reassurance that I have all these commands doing what they should be, because I _think_ they are right, but have no one I can ring up and just ask them if they are or not, so hopefully someone can tell me yes/no.

Ok so I figured out that I can mount a hdd as an ibay:

mount /dev/hdb0 /home/files/ibays/share1
(Primary IDE/slave/1st partition)?

And then I put in another hdd as another ibay:

mount /dev/hdc0 /home/files/ibays/share2
(Secondary IDE/Master/1st partition)?

And now I want to setup a cron task to copy newer files from share1, including all sub-directories, to share2 on a hourly basis so I need to put a file into the /etc/cron.hourly dir?

Do I just use pico to create the file?  pico /etc/cron.hourly/backup    ???  

And what do I need to put into the file to copy only newer files as I dont want it to be copying all the files across, just ones from share1 that are newer (in date) than the ones on share2, (including sub-directories) is it something like this:

01 * * * * cp -a -r -u /home/e-smith/files/ibays/share1 /home/e-smith/files/ibays/share2

Is that right, will it copy/update all files and sub-directories in share1 to share2 every _:01 of every hour?

Thanks in advance,

Cyrus Bharda

P.S. : How do I set it to mount the extra 2 drives on bootup, do I add these 2 lines to the bottom of /etc/fstab:  ?

/dev/hdb0 /home/files/ibays/share1 vfat defaults 1 2
/dev/hdc0 /home/files/ibays/share2 vfat defaults 1 2

Does SME support 80 Gig HDDs?

Thanks

Cyrus Bharda

Re: Just a little help setting up a Cron task
« Reply #1 on: September 04, 2002, 11:23:36 AM »
Ok so I made a couple of typos with the dirs, I meant:

/home/e-smith/files/ibays/

in all above instead of:

/home/files/ibays  

sorry :-))

Dan G.

Re: Just a little help setting up a Cron task
« Reply #2 on: September 04, 2002, 09:34:57 PM »
First, I think you'll want to use rsync to do what you are proposting, rather than cp.  Use rsync -auv /source /target --- this will preserve your timestamps, and will only copy changes within the files, not the entire files themselves on each cron pass.  Alter "source" and "target" to your local situation.

Second, make a template for your cron task:

mkdir -p /etc/e-smith/templates-custom/etc/crontab/

Then put your cron setup line in it.  This example would run the job every 5 minutes:

echo "0-59/5 * * * * root rsync -auv /source  /target" > /etc/e-smith/templates-custom/etc/crontab/rsyncCopy

Then expand the template:

/sbin/e-smith/expand-template /etc/crontab

If there are any errors in your rsync command line, you'll get a helpful email to your sysadmin account every 5 minutes.

As for mounting the drives at boot time, that's out of my league :)

Dan

Cyrus Bharda

Re: Just a little help setting up a Cron task
« Reply #3 on: September 05, 2002, 08:58:41 AM »
Thanks got the mount on bootup down pat, fstab stuff.

And thanks for the advice on the rsync, really REALLY appreciated!!

Cyrus Bharda