执行计划任务脚本,将登录失败用户直接拒绝

一、修改计划任务

vim /etc/crontab 

二、可以看到如下

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

即:
分钟(0-59) 小时(0-23) 日(1-31) 月(11-12) 星期(0-6,0表示周日) 用户名 要执行的命令

如下则表示,每时每分以root用户执行/root/iptables_cron.sh这个脚本

* * * * *  root bash /root/iptables_cron.sh

加载任务,使其生效

crontab /etc/crontab 

查看任务

crontab -l

具体示例如下:

每天凌晨一点以root用户执行一次/data/test.sh

* 1 * * * root /data/test.sh

这个文章目前有点问题,每次执行后都会把他放到防火墙中一次,还没来得及优化,仅供参考


如无计划任务,请按照以下步骤安装

一、安装计划任务执行包(大部分系统都会自带,)

yum install crontabs

二、将其设置为开机自启动

systemctl enable crond

三、开启服务

systemctl start crond

四、查看计划任务状态

systemctl status crond
 
------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------- 博客均为个人笔记,无所追求,仅供参考~~~ QQ--2382990774
原文地址:https://www.cnblogs.com/alexlv/p/14848822.html