Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| linux:linux-tutorials:send-command-output-via-email [2025/09/08 16:43] – removed - external edit (Unknown date) 127.0.0.1 | linux:linux-tutorials:send-command-output-via-email [2025/09/08 18:09] (current) – Zyzonix | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== Send output of command via email with sendmail ===== | ||
| + | This guide shows how to configure a script to send it's output via email. | ||
| + | Thereby that the '' | ||
| + | |||
| + | <panel type=" | ||
| + | <code bash> | ||
| + | #!/bin/bash | ||
| + | RECIPIENT=user@example.com | ||
| + | |||
| + | SCRIPT_DIR=$( cd -- "$( dirname -- " | ||
| + | SCRIPT_NAME=$(basename " | ||
| + | SENDER=root@$(/ | ||
| + | |||
| + | crontab () { | ||
| + | echo " | ||
| + | echo " | ||
| + | echo "From: $SENDER" | ||
| + | echo " | ||
| + | echo "To: $RECIPIENT" | ||
| + | |||
| + | # Commands to be run here | ||
| + | |||
| + | echo "" | ||
| + | echo " | ||
| + | } | ||
| + | |||
| + | crontab | sendmail -t $RECIPIENT | ||
| + | </ | ||
| + | </ | ||