这是一个shell脚本仓库,里面有很多实用的功能
- 禁止恶意ip登录
- 定时清除nacos产生的日志
- 通过一行脚本命令切换JDK版本
-
backup hosts.deny
cp /etc/hosts.deny /etc/hosts.deny.bak
-
create illegal_ip file
touch /xxx/illegal_ip_list.txt
-
create cron_task log file
touch /xxx/cron/task.log
-
create cron task, execute the script every 30 minutes
crontab -e */30 * * * * /xxx/deny_illegal_ip.sh
- replace $LOG_PATH and $ONE_MONTH_AGO_SECONDS in shell
LOG_PATH="/usr/nacos/bin/logs" ONE_MONTH_AGO_SECONDS=`date -d "30 day ago" "+%s"`
- create cron task, execute the script every day
crontab -e 0 0 * * * /usr/shell_study/clean_nacos_logs.sh
- replace $my_versions
# here are jdk versions you installed my_versions=([8]="/usr/java/jdk" [17]="/usr/java/jdk17")
- execute the script with target jdk version
source switch_jdk.sh version or . switch_jdk.sh version