Cron scripts anyone?

Glenn Crocker glenn at netmud.com
Thu Jun 14 13:26:13 CDT 2001


Jared,

Here's a script that does something similar to what you're wanting:

#!/bin/sh
cd
bakname=/home/someuser/backup/backup-`date +%s`.tar.gz
oldname=`ls /home/someuser/backup/backup-* | head -1`
rm $oldname
tar zcvf $bakname db/TinyCWRU.db.new db/TinyCWRU.gdbm*

I put that script in ~/.backup.cron, made sure it was chmod u+x, and added
this line to the user's cron (with 'crontab -e'):

0 8 * * * /home/someuser/.backup.cron

Note that this script also removes the oldest backup file in the directory
before writing a new one.  So you can keep 10 backup files (or whatever)
instead of all of them.  (To do this, do 'touch 1', 'touch 2', etc. in the
directory to create dummy files for it to remove as it "seeds" the
directory.)

-glenn

-----Original Message-----
From: jared [mailto:jared at mail.ru]
Sent: Thursday, June 14, 2001 1:34 AM
To: kclug at kclug.org
Subject: Cron scripts anyone?

If anybody on the list knows about cron scripting, i need some help.  (I
have no cron experience, unfortunately)

I need a script that will take the file "log" for example and move it to
/log/(date_goes_here_).log and then makes a new blank text file "log" where
the first "log" was.  This needs to do this every 24 hours.  It's a way to
keep my logs sorted without doing this manually.

Jared

P.S. a short tutorial on where to put the script or how to make it run
would be very handy





More information about the Kclug mailing list