如果想用 shell script 发送邮件,可以用 mail 实现:
# echo “email content” | mail -s “email subject” you@emaildomain
以上语句会发送一封标题为 “email subject” 的电邮到 you@emaildomain,其中 “email content” 为电邮内容。
以下简单的两行 shell script 便会将档案系统使用量,透过电邮发送给指定的电邮信箱:
#!/bin/sh
/bin/df -h | /usr/bin/mail -s “server capacity” you@emaildomain
/bin/df -h | /usr/bin/mail -s “server capacity” you@emaildomain