2025年5月17日星期六

Ubuntu 24.04 配置Crontab任务失败时邮件提醒

 
安装
sudo apt update && sudo apt install -y msmtp msmtp-mta

安装过程中弹出来的Configuring msmtp 选择No


配置(编辑后保存)

nano ~/.msmtprc

添加下面配置内容


account default
host smtp.163.com
port 465
from yourname@163.com
auth on
user yourname@163.com
password YOUR_CLIENT_AUTH_PASSWORD  # 邮箱授权密码
tls on
tls_starttls off
logfile ~/.msmtp.log


赋予读写权限

chmod 600 ~/.msmtprc


测试邮件发送
echo -e "Subject: Test\n\nThis is a test" | msmtp -a default yourname@163.com


检查日志
cat ~/.msmtp.log  # 看到状态码250表示成功


创建别名(替代系统 mail 命令)

nano ~/.bashrc


最末尾添加一行:

alias mail='msmtp -t'


使其环境变量生效
source ~/.bashrc


使用别名测试发送


echo -e "To: xxxxx@163.com\nSubject: Test\n\nThis is a test email" | mail


看日志验证发送结果


cat ~/.msmtp.log


crontab定时任务配置

crontab -e      首行添加一行

MAILTO="xxxxx@163.com"


* * * * * /task1.sh
0 * * * * /task2.sh  

...

task1 或者task2任务 只要执行失败就会发送到MAILTO设置的邮箱地址提醒


结束

2025年5月12日星期一

OpenWrt 24.10一键关闭IPV6

家里用不到IPV6,编译固件去掉IPV6的话,论坛里其他网友可能又有IPV6的需求

所以每次刷机后手动关闭吧,全部拷贝到ssh后台一键即可关闭。


uci set network.lan.ipv6='0'      

uci set network.wan.ipv6='0'      

uci set network.wan6.proto='none' 

uci set network.wan6.disabled='1'

uci set network.wan6.auto='0'

uci set dhcp.lan.dhcpv6='disabled'  

uci set dhcp.lan.ra='disabled'     

uci del firewall.cfg0892bd

uci del firewall.cfg0a92bd

uci del firewall.cfg0b92bd

uci del dhcp.lan.ra

uci del dhcp.lan.ra_slaac

uci del dhcp.lan.ra_flags

uci del dhcp.lan.dhcpv6

uci del network.lan.ip6assign

uci set network.lan.delegate='0'

uci del firewall.cfg0892bd

uci set firewall.cfg0992bd.family='ipv4'

uci set firewall.cfg0a92bd.family='ipv4'

uci commit

reboot

XG-040G-XX SuPassword 解密工具

 买了新光猫 XG-040G-TF ,  所以写了一个 SuPassword 解密工具, 以备不时之需 . 点击下载