Cron Job to send output to email in VMWare Virtual Appliance

Vincent Truong
Vincent Truong used Ask the Experts™
Need help creating VMware script to simply run the command below and email the output.  This will be setup as a cron job to run daily.   Any assistance is appreciated.

VCSA:~ # df -h
Filesystem                            Size  Used Avail Use% Mounted on
/dev/sda3                              11G  6.4G  3.8G  63% /
udev                                   12G  164K   12G   1% /dev
tmpfs                                  12G   40K   12G   1% /dev/shm
/dev/sda1                             128M   38M   84M  31% /boot
/dev/mapper/core_vg-core               50G   13G   34G  28% /storage/core
/dev/mapper/log_vg-log                 25G  8.2G   16G  35% /storage/log
/dev/mapper/db_vg-db                   25G  977M   23G   5% /storage/db
/dev/mapper/dblog_vg-dblog            9.9G  712M  8.7G   8% /storage/dblog
/dev/mapper/seat_vg-seat               50G  5.4G   42G  12% /storage/seat
/dev/mapper/netdump_vg-netdump        9.9G  151M  9.2G   2% /storage/netdump
/dev/mapper/autodeploy_vg-autodeploy   25G  173M   24G   1% /storage/autodeploy
/dev/mapper/invsvc_vg-invsvc           25G  981M   23G   5% /storage/invsvc
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fractional CTO
Distinguished Expert 2018
Take this step by step.

1) First make sure you can actually email from your source machine/container to your target recipient.

Keep in mind, if your recipient lives at a public Provider (Gmail, Hotmail, Yahoo, etc...) then use a relay service like MailGun to ensure your mail actually delivers.

Get your mail working before proceeding.

Hint: Many times feeding your command out output into SWAKS will be easiest way to send mail to a public Provider recipient.

2) Create your cron job, so say you'd like to check this every 4 hours...

0 */4 * * * df -h 2>&1 | swaks -tlsc -auth login -s $relay:587 -au $user -ap $pass --to=$recipient

Open in new window

Values for email delivery will vary depending on relay service you use.
Vincent TruongSr Server Developer


Thanks for the input.  We opted to utilize vCenter VM alerts for disks utilization which reflected in the system file for the VCSA.  I am going to keep this for future reference.
David FavorFractional CTO
Distinguished Expert 2018

Give MailGun a try for your relay service. First 10K messages/month are free with them, so for low volume applications, like what you just described... likely your monthly bill will be $0.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial