Admin-Ahead Community

Linux => General Linux => Topic started by: joseletk on April 21, 2018, 11:17:40 am

Title: Email the results of a command to you when it's finished
Post by: joseletk on April 21, 2018, 11:17:40 am
Some commands take longer to complete than your willing to wait. In times like this you can have the results emailed to you with this very simple trick. Here’s a basic example:

Code: [Select]
echo "apples" | mail -s "test" me@example.com -
The above would send the email right away with the word “apples” in it. But if the command was something more time consuming such as searching for a string within a bunch of files, you might do this:

Code: [Select]
grep -i "needle" * -R | mail -s "test" username@example.com -
And then wait for the email.
=========================================================================