LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-01-2005, 09:04 AM   #1
fizbang
LQ Newbie
 
Registered: Mar 2005
Posts: 3

Rep: Reputation: 0
Problem With Script in cron.daily


I found this script, modified it, got it working like I wanted and put it in cron.daily. Problem is, it keeps emailing me messages. This is what it mails

/bin/tar: Removing leading `/' from member names
/dev/sda on /mnt type vfat (rw)

How do I suppress these messages? I don't see any quiet options. Maybe it would be better if I ran it from root's crontab?

Here is the script.

#!/bin/sh
# full and incremental backup script
# created 07 February 2000
# Based on a script by Daniel O'Callaghan <danny@freebsd.org>
# and modified by Gerhard Mourani <gmourani@videotron.ca>

#Change the 5 variables below to fit your computer/backup

COMPUTER=deep # name of this computer
DIRECTORIES="/home" # directoris to backup
BACKUPDIR=/mnt/backups # where to store the backups
TIMEDIR=/mnt/backups/last-full # where to store time of full backup
TAR=/bin/tar # name and locaction of tar

#You should not have to change anything below here

PATH=/usr/local/bin:/usr/bin:/bin
DOW=`date +%a` # Day of the week e.g. Mon
DOM=`date +%d` # Date of the Month e.g. 27
DM=`date +%d%b` # Date and Month e.g. 27Sep

# On the 1st of the month a permanet full backup is made
# Every Sunday a full backup is made - overwriting last Sundays backup
# The rest of the time an incremental backup is made. Each incremental
# backup overwrites last weeks incremental backup of the same name.
#
# if NEWER = "", then tar backs up all files in the directories
# otherwise it backs up files newer than the NEWER date. NEWER
# gets it date from the file written every Sunday.

# mount drive
if mount | grep sda
then cat /bin/date>/dev/null
#nothing
else mount /dev/sda /mnt>/dev/null
fi

# Monthly full backup
if [ $DOM = "01" ]; then
NEWER=""
$TAR $NEWER -chf $BACKUPDIR/$COMPUTER-$DM.tar $DIRECTORIES>/dev/null
fi

# Weekly full backup
if [ $DOW = "Sun" ]; then
NEWER=""
NOW=`date +%d-%b`

# Update full backup date
echo $NOW > $TIMEDIR/$COMPUTER-full-date
$TAR $NEWER -chf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES>/dev/null

# Make incremental backup - overwrite last weeks
else
# Get date of last full backup
NEWER="--newer `cat $TIMEDIR/$COMPUTER-full-date`"
$TAR $NEWER -chf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES>/dev/null
fi

# umount drive
if mount | grep sda
then umount /dev/sda>/dev/null
fi
 
Old 03-01-2005, 10:07 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

tar removes the leading slash by default. 2 ways of getting rid of this message:

1) use tar's -p option
2) use grep -v to get rid of this message.

Be sure to know the implementations of tarring files _with_ the leading slash (-p option)!! The creation is not effected, but during extraction you could end up with problems because the filepath is 'hard'.

Hope this helps.
 
Old 03-01-2005, 03:04 PM   #3
fizbang
LQ Newbie
 
Registered: Mar 2005
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks, but it didn't help.

Hmmmm... I'm using Debian Woody. Grep doesn't have a -v switch and tar doesn't have a -p switch. I silenced the greps by sending the output to /dev/null but I still can't silence tar.

Tar says: /bin/tar: Removing leading `/' from member names

even if I send it to /dev/null.
 
Old 03-01-2005, 03:35 PM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi again,

No -v option for grep? That I don't believe....... Same about the -p option for tar.
I must admit that it should be -P, not -p but both are there. tar --help and man grep for details about these options.

If you want to redirect the output you also need to redirect the errors (stderr), so do:

> dev/null 2>&1 instead of only >/dev/null

Hope this helps.
 
Old 03-01-2005, 04:58 PM   #5
fizbang
LQ Newbie
 
Registered: Mar 2005
Posts: 3

Original Poster
Rep: Reputation: 0
that did it, thanks!
 
Old 03-21-2005, 09:32 AM   #6
lsimon4180
Member
 
Registered: Oct 2004
Location: Chicago, IL
Distribution: Fedora Core 2
Posts: 101

Rep: Reputation: 15
Hey all,

I'm having the same problem:

/etc/cron.daily/backup.cron:

/bin/tar: Removing leading `/' from member names

You mentioned to use grep -v or tar -p and > dev/null 2>&1 instead of only >/dev/null

Where does this info go?

Correct me if I am wrong but doesn't > dev/null 2>&1 instead of only >/dev/null go in the cromtab file?

How about the grep -v or tar -p solution?

Thanks,
 
Old 03-21-2005, 09:53 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

It does not matter where you put the >/dev/null 2>&1. Personally I like my crontab as clean as possible and like to handle output from within the script.

tar -P (capital) makes sure that tar does not strip the leading /. Like I stated in post #2: Do know what this implies during restore.

If you use >/dev/null 2>&1 after your tar command you don't need the grep -v. If you use tar -P you don't need the /de/null..... and/or the grep -v

Hope this helps.

Last edited by druuna; 03-21-2005 at 09:54 AM.
 
Old 03-21-2005, 09:58 AM   #8
lsimon4180
Member
 
Registered: Oct 2004
Location: Chicago, IL
Distribution: Fedora Core 2
Posts: 101

Rep: Reputation: 15
Thanks so much for the reply, below is a copy of the file. Can you do me a big favor and point out where I need to place this extra bit of code?

Can you please explain what you ment in Post 2? Is this a bad thing to do, the tar -P?

************************************

COMPUTER=**** # name of this computer
DIRECTORIES="*****" # directoris to backup
BACKUPDIR=/backups # where to store the backups
TIMEDIR=/backups/last-full # where to store time of full backup
TAR=/bin/tar # name and locaction of tar

#You should not have to change anything below here

PATH=/usr/local/bin:/usr/bin:/bin
DOW=`date +%a` # Day of the week e.g. Mon
DOM=`date +%d` # Date of the Month e.g. 27
DM=`date +%d%b` # Date and Month e.g. 27Sep

# On the 1st of the month a permanet full backup is made
# Every Sunday a full backup is made - overwriting last Sundays backup
# The rest of the time an incremental backup is made. Each incremental
# backup overwrites last weeks incremental backup of the same name.
#
# if NEWER = "", then tar backs up all files in the directories
# otherwise it backs up files newer than the NEWER date. NEWER
# gets it date from the file written every Sunday.


# Monthly full backup
if [ $DOM = "1" ]; then
NEWER=""
$TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DM.tar $DIRECTORIES
fi

# Weekly full backup
if [ $DOW = "Thu" ]; then
NEWER=""
NOW=`date +%d-%b`

# Update full backup date
echo $NOW > $TIMEDIR/$COMPUTER-full-date
$TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES

# Make incremental backup - overwrite last weeks
else

# Get date of last full backup
NEWER="--newer `cat $TIMEDIR/$COMPUTER-full-date`"
$TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES


**************************

Does it go after TAR=/bin/tar?

Thanks,

LS
 
Old 03-21-2005, 10:09 AM   #9
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

About tar -P:

This option will not strip the leading / from paths. Untarring the created archive will place the file at the 'hard' location (i.e. /etc/fstab will be placed at /etc/fstab). This sounds great, but is often unwanted because it overwrites the excisting file(s) without asking.

Without the -P tar will strip the leading / (/etc/fstab becomes etc/fstab). If you untar the archive in say /tmp, /tmp/etc/fstab is created and the original /etc/fstab is left alone. It's then up to you to decide which files do actually need to be replaced.

Tarring without the -P option is saver, although it takes a bit more time.

This will not use the -P option, but does throw away the message about it:
Add the bold part to all three instances in your backup script:
$TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DM.tar $DIRECTORIES >/dev/null 2>&1

If you do want to use the -P option, add the bold part to all three instances:
$TAR -P $NEWER -cf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES

Hope this clears things up.
 
Old 03-21-2005, 10:21 AM   #10
Itzac
Member
 
Registered: Feb 2003
Distribution: VectorLinux 5.1
Posts: 116

Rep: Reputation: 15
It would probably be easiest to just add the > /dev/null 2>&1 inside the crontab. Otherwise you need to add it to the end of each line in the script that starts with $TAR. By doing this you basically redirect all output from tar to the trash. Cron is designed so that anything that is output by the programs it runs will be emailed to the user. We just prevent cron from receiving any of this output.
 
Old 03-21-2005, 10:23 AM   #11
lsimon4180
Member
 
Registered: Oct 2004
Location: Chicago, IL
Distribution: Fedora Core 2
Posts: 101

Rep: Reputation: 15
Thanks so much, I'll let you know if that work...I also get the following error in the same email:

/etc/cron.daily/00webalizer:

Error: Skipping oversized log record
Warning: Truncating oversized referrer field


removed the 00webalizer file so I wont get them anymore, but I was wondering if this looks familiar to you. I looked on line and couldnt find a fix for it, everyine just says to remove it.

any ideas?

thanks a bunch

Lenny
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron.daily reporting a squidGuard config problem kalahari875 Mandriva 3 10-03-2004 11:14 AM
crontab vs cron.daily ? SheldonPlankton Linux - Newbie 1 07-16-2004 12:10 PM
cron.daily error gjmwalsh Mandriva 2 10-29-2003 02:12 PM
cron.daily MrJoshua Linux - General 2 03-19-2003 12:09 PM
dual entries in cron log for cron.daily cpharvey Linux - General 3 02-27-2003 02:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration