<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: E-Mail Notification After Tar is Complete in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885755#M25705</link>
    <description>You can use last exit code - $? &lt;BR /&gt;For example :&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;tar ....... &lt;BR /&gt;&lt;BR /&gt;if [ $? ]; &lt;BR /&gt;then &lt;BR /&gt; mail "tar is OK" ...&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;ivan</description>
    <pubDate>Tue, 24 Oct 2006 13:47:40 GMT</pubDate>
    <dc:creator>Ivan Krastev</dc:creator>
    <dc:date>2006-10-24T13:47:40Z</dc:date>
    <item>
      <title>E-Mail Notification After Tar is Complete</title>
      <link>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885753#M25703</link>
      <description>Hi there --&lt;BR /&gt;&lt;BR /&gt;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.</description>
      <pubDate>Tue, 24 Oct 2006 13:27:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885753#M25703</guid>
      <dc:creator>Andrew Kaplan</dc:creator>
      <dc:date>2006-10-24T13:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: E-Mail Notification After Tar is Complete</title>
      <link>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885754#M25704</link>
      <description>Just check the return code for the tar command:&lt;BR /&gt;&lt;BR /&gt;tar c /some/path&lt;BR /&gt;RC=$?&lt;BR /&gt;&lt;BR /&gt;if [ ${RC} -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;  echo "tar was successful"&lt;BR /&gt;else&lt;BR /&gt;  echo "tar was unsuccessful. Return code was ${RC}."&lt;BR /&gt;fi</description>
      <pubDate>Tue, 24 Oct 2006 13:47:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885754#M25704</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2006-10-24T13:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: E-Mail Notification After Tar is Complete</title>
      <link>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885755#M25705</link>
      <description>You can use last exit code - $? &lt;BR /&gt;For example :&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;tar ....... &lt;BR /&gt;&lt;BR /&gt;if [ $? ]; &lt;BR /&gt;then &lt;BR /&gt; mail "tar is OK" ...&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;ivan</description>
      <pubDate>Tue, 24 Oct 2006 13:47:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885755#M25705</guid>
      <dc:creator>Ivan Krastev</dc:creator>
      <dc:date>2006-10-24T13:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: E-Mail Notification After Tar is Complete</title>
      <link>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885756#M25706</link>
      <description>And if you want the email to go to a user other than the one running the script via cron, you can pipe the echo commands above to the mail program:&lt;BR /&gt;&lt;BR /&gt;echo "My message" | mailx -s "tar job status" yourname@company.com</description>
      <pubDate>Tue, 24 Oct 2006 13:48:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885756#M25706</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2006-10-24T13:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: E-Mail Notification After Tar is Complete</title>
      <link>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885757#M25707</link>
      <description>Hi there --&lt;BR /&gt;&lt;BR /&gt;I created a script using the syntax that was mentioned in a previous reply. Here is what it looks like so far:&lt;BR /&gt;&lt;BR /&gt;# This script is designed to run selective nightly backups &lt;BR /&gt;# on the Hadron server to the locally attached tape drive &lt;BR /&gt;# via the tar utility. Once the tape backup is complete, &lt;BR /&gt;# an e-mail notification is sent out to nofify the system &lt;BR /&gt;# administrator on the success or failure of the backup.&lt;BR /&gt;&lt;BR /&gt;# Prior to running this script, ensure there is a backup_list.txt &lt;BR /&gt;# file located in the /root directory. This file is necessary in &lt;BR /&gt;# order for there to be a selective backup job.&lt;BR /&gt;&lt;BR /&gt;# cd /root&lt;BR /&gt;&lt;BR /&gt;# Run the following command in order to complete the selective &lt;BR /&gt;# backup of the server.&lt;BR /&gt;&lt;BR /&gt;sh -c 'tar -cf /dev/st0 $(cat /root/backup_list.txt)'&lt;BR /&gt;&lt;BR /&gt;# The following commands determine if the above command was successful, &lt;BR /&gt;# and send the appropriate notification via e-mail.&lt;BR /&gt;&lt;BR /&gt;RC=$?&lt;BR /&gt;&lt;BR /&gt;if [${RC} -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo "Hadron nightly backup was completed successfully" | mailx -s "Hadron Nightly Backups" ahkaplan@partners.org &lt;BR /&gt;else &lt;BR /&gt;echo "Hadron nightly backup was not successfully completed. The return code was ${RC}." | mailx -s "Hadron Nightly Backups" ahkaplan@partners.org &lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;I have two questions:&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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.</description>
      <pubDate>Tue, 24 Oct 2006 15:17:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885757#M25707</guid>
      <dc:creator>Andrew Kaplan</dc:creator>
      <dc:date>2006-10-24T15:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: E-Mail Notification After Tar is Complete</title>
      <link>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885758#M25708</link>
      <description>For file checking see this article - &lt;A href="http://linuxreviews.org/beginner/bash_GNU_Bourne-Again_SHell_Reference/#toc2" target="_blank"&gt;http://linuxreviews.org/beginner/bash_GNU_Bourne-Again_SHell_Reference/#toc2&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Best way is to use -s (Check if file has size greater than 0)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;ivan</description>
      <pubDate>Tue, 24 Oct 2006 15:30:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885758#M25708</guid>
      <dc:creator>Ivan Krastev</dc:creator>
      <dc:date>2006-10-24T15:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: E-Mail Notification After Tar is Complete</title>
      <link>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885759#M25709</link>
      <description>Make sure there's a space between [ and ${RC}.</description>
      <pubDate>Tue, 24 Oct 2006 16:28:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885759#M25709</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2006-10-24T16:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: E-Mail Notification After Tar is Complete</title>
      <link>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885760#M25710</link>
      <description>And to check for the existence of the file:&lt;BR /&gt;&lt;BR /&gt;if [ ! -f /root/backup_list.txt ]&lt;BR /&gt;then&lt;BR /&gt;  echo "No backup list file. Exiting"&lt;BR /&gt;  exit&lt;BR /&gt;fi</description>
      <pubDate>Tue, 24 Oct 2006 16:31:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885760#M25710</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2006-10-24T16:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: E-Mail Notification After Tar is Complete</title>
      <link>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885761#M25711</link>
      <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;besides the missing space in the test operator: there is no need to wrap the tar command into a sh call:&lt;BR /&gt;&lt;BR /&gt;Change&lt;BR /&gt;sh -c 'tar -cf /dev/st0 $(cat /root/backup_list.txt)'&lt;BR /&gt;to&lt;BR /&gt;tar cf /dev/st0 $(RC=$?&lt;BR /&gt;&lt;BR /&gt;if [  $RC -eq 0 ]&lt;BR /&gt;then echo OK-message&lt;BR /&gt;else echo FAIL-$RC-message&lt;BR /&gt;fi | mailx -s Backup-Msg to_user@addr&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The $(&amp;lt;..) can be used as a substitute in ksh/bash/zsh .&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Wed, 25 Oct 2006 05:53:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885761#M25711</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-10-25T05:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: E-Mail Notification After Tar is Complete</title>
      <link>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885762#M25712</link>
      <description>Thanks to all for your help. I have the script completed, and it appears to be working quite well.</description>
      <pubDate>Wed, 25 Oct 2006 08:01:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/e-mail-notification-after-tar-is-complete/m-p/3885762#M25712</guid>
      <dc:creator>Andrew Kaplan</dc:creator>
      <dc:date>2006-10-25T08:01:43Z</dc:date>
    </item>
  </channel>
</rss>

