LinuxQuestions.org
Register a domain and help support LQ
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 05-03-2011, 09:29 AM   #1
amario26
LQ Newbie
 
Registered: Apr 2011
Posts: 11

Rep: Reputation: 0
E-Mailing whole output of a file with crontab


Hi,

I have this code that is 'bashed' regularly with crontab and basically it will send me an E-Mail of most of the output but it misses out some of it!

Here is the crontab code to automatically run the script:
Code:
10 14,15 * * 1-5 bash /home/user/RoutineBackupTest.sh | mailx -s "Backup Log for `date +\%d_\%m_\%Y_\%H_\%M`" first.lastname@someone.com
So that sends me an E-mail with most of the output of the following code:

Code:
.......
elif [ $DAY_OF_WEEK == 2 ] 
then
echo
echo "*******" "Begin Removing All Previous Log Files" "*******"
rm ./*cron.log
echo
echo "*******" "Begin Removing Files" "*******" 
ssh username@servername rm ./../test/Tuesday/*.gz
echo
echo "*******" "Checking the following directories: $BACKUP" "*******"
echo
set -- $BACKUP
DIRS=$@
for i in "$@"
do
if [ -d $i ]; then
echo "Directory $i exists"
else
echo "!!!!!!! Directory $i doesnt exist - This directory will not be backed up. Your backup will continue as normal, skipping this directory. !!!!!!!"
echo
fi
done
echo "*******" "Begin compressing and transferring files" "*******"
echo
tar -czpv $BACKUP | ssh -c blowfish username@servername "dd of=/home/test/Tuesday/$(date '+%d_%m_%y_%H_%M')__AmarioTestBackup.tar.gz" 
elif [ $DAY_OF_WEEK == 3 ] 
then
echo
.......
It sends me everything up to echo "*******" "Begin compressing and transferring files" "*******" but it wont output the tar bit.. so it should give me a list of files that have been tarred.

Any help would be greatly appreciated.

Many thanks!

Amario
 
Old 05-03-2011, 11:44 AM   #2
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
tee

I think you need a tee command to direct output to the ssh process and stdout/stderr.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Crontab doesn't give the output of the file it runs in terminal pranavojha Linux - Software 3 08-24-2013 04:19 PM
[SOLVED] Bash+crontab output is in different language jmvidalvia Linux - General 4 04-06-2011 04:37 AM
VERY simple crontab question about mailing results Barefootpanda Linux - General 4 03-03-2009 10:45 AM
Crontab/Shell Output problem mdx34 Linux - Newbie 5 09-12-2008 04:31 PM
cron job mailing blank output rsmccain Linux - General 4 10-09-2006 04:00 PM


All times are GMT -5. The time now is 09:23 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration