Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Cron

Status
Not open for further replies.

Eddiefdz

IS-IT--Management
Joined
Mar 20, 2002
Messages
273
Location
US
Hello,

I am having a little problem with the output of a cron job that i want emailed to me. I have the following in a cron job:

MAILTO:my@mydomain.com
00 22 * * * /bak/trash/rsync_backup

Ok, so this is supposed to run this backup script that i created called rsync_backup and then email me the output.
Well it does email me the out put but it seems to only send me the ending page. The output of this file should be several pages long as it backs up every directory. When i check the logs i see that its about 8 pages long but on the email i seem to only get the last page. Am I missing somthing here so that it emails everyhting??? Pleas let me know.

Thanks,
Eddie

Eddie Fernandez
CCNA, Network+, A+, MCP
 
try
00 22 * * * /bak/trash/rsync_backup 2>&1 1>/tmp/backup.txt; mail my@domain.com < /tmp/backup.txt

I'm doing that from memory, but should work. You could, of course, add that to your script and not clutter up the crontab....

 
maybe the script can do the emailing? standard distros have the 'mail' command...

you can do somethign liek this:

rsync -av <whatever options you have> <source> <dest> &> /some/file

mail -s "rsync output" email@email.com < /some/file >/dev/null

and just adjust &> to whatever you want depending what you want to see. of course, you have to make sure mail and your smtp are set up.

just an idea. probaly better ways of doing it.
 
You don't need a temp file, and there's no reason to redirect each individual command.

Code:
#!/bin/bash -p

PATH=/bin:/usr/bin

{ exec 2>&1 

do
all 
your
processing
here

} | mail -s 'Job Output' you@yourdomain.tld
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top