Clever Uses For ‘mail’ On The Command Line

Being able to notify yourself when processes on the command line complete has been one of the most helpful things I’ve discovered in the last two years.

So, for example when I have to stop and start some instances and I want to shift my attention to something else, having mail send me a notification via SMTP through my cell phone provider’s email-to-text gateway is a great way to let me know when something is done. For example:

relaunch $SERVERS; mail -s "$TICKET_ID - Relaunch of $SERVERS has completed!" (REDACTED)@example.com < /dev/null

Having this kind of notification is great and lets me keep working on other issues without losing track of things that are happening ‘in the background’. Similarly, I use it for an increasing number of relatively mundane tasks:

  • MySQL upgrade runs (mysql_upgrade)
  • Instance/host stop/starts
  • Database restore operations
  • Other time-intensive, low-impact tasks

It’s a very simple hack to add to your workflow, and I’d love to hear your feedback! Tweet @e1nh4nd3r with your thoughts!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s