Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Email Alerts for Shell Scripts

    I am trying to setup email alerts for a script that runs and stores the backup files of our HANA database onto a shared location. Below is the simple script i wrote and it is moves the files from the default storage location to network storage everyday.

    mkdir /mnt/hana/`date +%y%m%d`
    if mv /usr/sap/TNP/HDB01/backup/data_test/* /mnt/hana/`date +%y%m%d` #
    then echo "Copy successful " # >> $log_file
    else echo "Copy failed " # >> $log_file

    Could someone tell me how can i setup email alerts for this? The outputs Copy Succesful and Copy failed shows up in PUTTY as of now.

    Will there be any server (smtp) settings on the server that need be configured? I would appreciate if someone can guide me how to implement this.


  2. #2
    Linux Guru
    Join Date
    Dec 2013
    Victoria, B.C. Canada
    Without knowing anything about your setup I'd say you do need to setup sendmail to relay. If that is setup then it is simple to use the program mail from a bash script. Since you're posting to the SuSE forum you can start here for a relay: Linux Email Support Tips Sendmail

    Here's a sample bash script: Send mail bash script

  3. #3
    Most cron jobs are set up to redirect standard out and standard error to /dev/null (black hole). You can, instead, send the output of the script to a log file by executing

    command > /path/to/log

    to capture anything that would normally be written to the console. Then, start up another cron job whose job is to grab that text file and stuff it into an email similar to the example posted above.

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts