From owner-freebsd-questions Mon Dec 4 6:11:38 2000 From owner-freebsd-questions@FreeBSD.ORG Mon Dec 4 06:11:36 2000 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mailhost.esil.univ-mrs.fr (jiyu.esil.univ-mrs.fr [139.124.44.249]) by hub.freebsd.org (Postfix) with ESMTP id A9C1B37B400 for ; Mon, 4 Dec 2000 06:11:32 -0800 (PST) Received: from es2irk18 (cam@es2irk18.esil.univ-mrs.fr [139.124.21.118]) by mailhost.esil.univ-mrs.fr (8.9.3/ESIL/jtpda-5.3.1) with SMTP id PAA77446 ; Mon, 4 Dec 2000 15:11:20 +0100 (CET) Message-Id: <200012041411.PAA77446@mailhost.esil.univ-mrs.fr> Date: Mon, 4 Dec 2000 16:15:38 +0100 From: cam To: "Hans Johannsson" Cc: freebsd-questions@FreeBSD.ORG Subject: Re: SV: CRON ?! Executable file ?! In-Reply-To: <200012041400.PAA20990@epsilon.swip.net> References: <200012041400.PAA20990@epsilon.swip.net> X-Mailer: Sylpheed version 0.4.2 (GTK+ 1.2.7; Linux 2.2.17; i686) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, 4 Dec 2000 15:00:41 +0100 (MET) "Hans Johannsson" 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" 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