Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:linux-tutorials:send-command-output-via-email [2025/09/08 16:43] – ↷ Page name changed from linux:linux-tutorials:send-crontab-output-via-email to linux:linux-tutorials:send-command-output-via-email Zyzonixlinux:linux-tutorials:send-command-output-via-email [2025/09/08 18:09] (current) Zyzonix
Line 1: Line 1:
-===== Send output of crontab via email with sendmail =====+===== Send output of command via email with sendmail =====
  
-This guide shows how to configure a crontab script to send it's output via email. +This guide shows how to configure a script to send it's output via email. 
-Thereby that the ''MAILTO='' setting in crontabs is global, it's not that easy to send an email to a different address from another crontab files.+Thereby that the ''MAILTO='' setting in crontabs is global, it's not that easy to send an email to a different address from another crontab files. This function/script can be used to send the output of a crontab to a different address:
  
-The crontab should then look like this: +<panel type="primary" icon="glyphicon glyphicon-file" title="/path/to/script">
-<panel type="primary" icon="glyphicon glyphicon-file" title="/path/to/crontab">+
 <code bash> <code bash>
 #!/bin/bash #!/bin/bash
Line 15: Line 14:
  
 crontab () { crontab () {
 + echo "MIME-Version: 1.0"
 +        echo "Content-Type: text/plain; charset=\"UTF-8\""
         echo "From: $SENDER"         echo "From: $SENDER"
-        echo "Subject: Cron <$SENDER> $SCRIPT_DIR/$SCRIPT_NAME "+        echo "Subject: <$SENDER> $SCRIPT_DIR/$SCRIPT_NAME "
         echo "To: $RECIPIENT"         echo "To: $RECIPIENT"
  
Line 22: Line 23:
  
         echo ""         echo ""
-        echo "Crontab location: $SCRIPT_DIR/$SCRIPT_NAME"+        echo "Script location: $SCRIPT_DIR/$SCRIPT_NAME"
 } }
  
  • linux/linux-tutorials/send-command-output-via-email.1757342584.txt.gz
  • Last modified: 2025/09/08 16:43
  • by Zyzonix