- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- E-Mail Notification After Tar is Complete
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2006 06:27 AM
10-24-2006 06:27 AM
I am going to be setting up a script that will run a tar job at a particular time every night. I would like to have an e-mail notification set up to let me know whether or not the job completed successfully. How would I go about doing that? Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2006 06:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2006 06:47 AM
10-24-2006 06:47 AM
Re: E-Mail Notification After Tar is Complete
For example :
tar .......
if [ $? ];
then
mail "tar is OK" ...
fi
regards,
ivan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2006 06:48 AM
10-24-2006 06:48 AM
Re: E-Mail Notification After Tar is Complete
echo "My message" | mailx -s "tar job status" yourname@company.com
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2006 08:17 AM
10-24-2006 08:17 AM
Re: E-Mail Notification After Tar is Complete
I created a script using the syntax that was mentioned in a previous reply. Here is what it looks like so far:
# This script is designed to run selective nightly backups
# on the Hadron server to the locally attached tape drive
# via the tar utility. Once the tape backup is complete,
# an e-mail notification is sent out to nofify the system
# administrator on the success or failure of the backup.
# Prior to running this script, ensure there is a backup_list.txt
# file located in the /root directory. This file is necessary in
# order for there to be a selective backup job.
# cd /root
# Run the following command in order to complete the selective
# backup of the server.
sh -c 'tar -cf /dev/st0 $(cat /root/backup_list.txt)'
# The following commands determine if the above command was successful,
# and send the appropriate notification via e-mail.
RC=$?
if [${RC} -eq 0 ]
then
echo "Hadron nightly backup was completed successfully" | mailx -s "Hadron Nightly Backups" ahkaplan@partners.org
else
echo "Hadron nightly backup was not successfully completed. The return code was ${RC}." | mailx -s "Hadron Nightly Backups" ahkaplan@partners.org
fi
I have two questions:
1. I am encountering an error with the line if [${RC} -eq 0 ]. The error I get is [0: command not found. I am guessing the syntax is wrong, but I don't know what the correction should be.
2. Earlier in the script I want to check for the presence of a backup_list.txt file in the /root directory. What syntax would I use to check for the file, and if it is not there exit with and error 1 status, and continue if it is there? Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2006 08:30 AM
10-24-2006 08:30 AM
Re: E-Mail Notification After Tar is Complete
Best way is to use -s (Check if file has size greater than 0)
regards,
ivan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2006 09:28 AM
10-24-2006 09:28 AM
Re: E-Mail Notification After Tar is Complete
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2006 09:31 AM
10-24-2006 09:31 AM
Re: E-Mail Notification After Tar is Complete
if [ ! -f /root/backup_list.txt ]
then
echo "No backup list file. Exiting"
exit
fi
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2006 10:53 PM
10-24-2006 10:53 PM
Re: E-Mail Notification After Tar is Complete
besides the missing space in the test operator: there is no need to wrap the tar command into a sh call:
Change
sh -c 'tar -cf /dev/st0 $(cat /root/backup_list.txt)'
to
tar cf /dev/st0 $(RC=$?
if [ $RC -eq 0 ]
then echo OK-message
else echo FAIL-$RC-message
fi | mailx -s Backup-Msg to_user@addr
The $(<..) can be used as a substitute in ksh/bash/zsh .
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2006 01:01 AM
10-25-2006 01:01 AM