Error function with email

    0

    0

    bashmailerror

    Send an email on error in a function in bash

    Library: Scripting et automatismes

    emailalerte="mail@mail.com"
    function erreur {
      echo $1
      cat /home/data/logs/sauvegarde-bs.log | mail -s "Erreur de sauvegarde vers Stockage $date" $emailalerte
      DATE_FIN_SAUVEGARDE=`date`
      echo "   FIN SAUVEGARDE LE $DATE_FIN_SAUVEGARDE" >> $LPATHLOGRSYNC
      exit 1
    }
    erreur("message")
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.