linux定时禁用启用防火墙端口

69 阅读1分钟

1.运行 crontab -e

2.添加命令

# 开启443端口
30 08 * * * firewall-cmd --zone=public --add-port=443/tcp --permanent
32 08 * * * systemctl restart firewalld.service

# 禁用443端口
30 18 * * * firewall-cmd --zone=public --remove-port=443/tcp --permanent
32 18 * * * systemctl restart firewalld.service

3.退出保存

4.关闭定时任务:service crond stop 5.重启定时任务:service crond start