1、指令发送邮件
echo "content"|mail -vs "this is title" -a a.sh [email protected]
其中,content代表发送的内容,thisistitle代表邮件主题,a.sh为附件
2、开机运行脚本
在etc/init.d下新建脚本sendmail.sh,输入内容并赋予权限(chmod +x sendmail.sh)
首先在init.d目录下输入runlevel查看等级,确定为5后对应的是rc5.d
(好像不用加软连接,加了后收到两封。。)然后建立软连接:ln -s /etc/init.d/sendmail.sh /etc/rc5.d/S99sendmail.sh
3、终端记录保存到文件
以ls指令为例
ls|tee -a /home/a.txt