We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,628 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

how to create logfile

#!/bin/bash
LOGFILE=/var/log/backup.log 
backup_source="/home"
backup_dest="/home/sean"
date=`date '+%d-%B-%Y'`
hostname=$(hostname -s)
filename="$hostname-$date.tgz"
echo "Backing Up your Linux System"
tar cvpzf $backup_dest/$filename $backup_source
LOGFILE="log-$date.log"
log(){
    message="$@"
    echo $message
    echo $message >>$LOGFILE    
}

log "$LOGFILE"
log | tee install.log

echo "Backup finished"
echo "$LOGFILE"

hie I'm trying append teh files i have backed up into log file. All i get is a blank logfile. This what i have so far

3
Contributors
2
Replies
1 Week
Discussion Span
3 Months Ago
Last Updated
3
Views
ashleytauari
Newbie Poster
1 post since Feb 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

The argument to the function log is just "log-$date.log". So only that will go to the log file. Try "ls -l (SOURCE DIRECTORY)" as the argument to the log function.

NOTE: Use the -r option to append the files into the tar archive. Using -c option will create new archive every time.

Hope it helps.

rustysynate
Newbie Poster
24 posts since Jun 2009
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0

Why don't you put directly tee as piped from the tar -v command?

LOGFILE="log-$date.log"
tar cvpzf $backup_dest/$filename $backup_source | tee $LOGFILE
CGSMCMLXXV
Junior Poster in Training
54 posts since Jan 2013
Reputation Points: 5
Solved Threads: 7
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0617 seconds using 2.69MB