Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Dec 2000 16:15:38 +0100
From:      cam <cam@bsdfr.org>
To:        "Hans Johannsson" <hj72@everyday.com>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: SV: CRON ?! Executable file ?!
Message-ID:  <200012041411.PAA77446@mailhost.esil.univ-mrs.fr>
In-Reply-To: <200012041400.PAA20990@epsilon.swip.net>
References:  <200012041400.PAA20990@epsilon.swip.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 4 Dec 2000 15:00:41 +0100 (MET)
"Hans Johannsson" <hj72@everyday.com> wrote:

> Wow....Thats a little bit too advanced for me....:).....could you please do a short explanation for the each step.
yep of course :)
> 
> 
> On Mon, 4 Dec 2000 14:18:28 +0100 (MET)
> > "Hans Johannsson" <hj72@everyday.com> wrote:
> > 
> > > Hi.
> > > Im running a freebsd version called IPSO. Its kinda like a stripped
> > freebsd version 4.0 or later i think.
> > > Id like to start CRON jobs. I know how to make the cron -e command,
> > and
> > how to configure the time or date i want it to execute, but i cant get
> > it
> > to execute the commands ive typed into a file.  I made a file in VI. I
> > dont
> > know if thats the right thing. And saved it with the regular :w , :q! .
> > > I want to use CRON  to take backups of files, every sunday.
> > > The vi file contains the dirs and files i want to backup.
> > > Anyone know how to help me out ?!
> > >
> > > /Hans
> > >
> > #! /usr/bin/bash
here we define the script language, I choose bash
> >
> > # directory to save your files
> > SAVE="/tmp/backup"
this is just a variable declaration that you can change to *your* value
> > 
> > # your vi file
> > VI="/home/me/my.vi.file"
idem, 'my.vi.file' is your "The vi file contains the dirs and files i want to backup."
> > 
> > mkdir $SAVE
> > if [ $? = 0 ]; then
> >   echo The directory $SAVE has been created.
> > fi
here we make a directory to contains your backups, and print it if it doesn't exists
> > 
> > for i in $(cat $VI); do
> >   cp $i $SAVE
> > done
next, for each line of the my.vi.file file, which represent a filename, we copy it to our backup directory, we can change "cp $i $SAVE" with "cp $i $SAVE/$(date "+%y%m%d")-$i" to preserve the old files
> > 
> > ********** END ***********
> > 
> > don't forget to "chmod +x thescript"
you have to chmod +x my script to be able to run it

next, pur into your cron -e:
1 3 * * * /path/myfile > /dev/null 2>&1

the "> /dev/null 2>&1" part is necessary if you don't want to receive an email each time
> > 
> > bye
> > cam
> > 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200012041411.PAA77446>