重置kubernetes集群配置,危险操作 第一步,删除配置 # 删除配置 df -h|grep kubelet |awk -F % ‘{print $2}’|xargs umount rm /var/lib/kubelet/* -rf rm /etc/kubernetes/* -rf rm /var/lib/rancher/* -rf rm /var/lib/etcd/* -rf rm /var/lib/cni/* -rf 第二步,重置网络插件 # 删除网络插件 rm -rf /var/run/calico # 刷新iptables iptables -F && iptables -t nat -F ip link del flannel.1 第三步、停止和删除容器和卷 # 停止和删除容器和卷 docker ps -a|awk ‘{print $1}’|xargs …
Author Archives: 李大仁
Crontab定时任务使用virtualenv/conda问题
Crontab定时任务使用virtualenv/conda会出现无法激活环境 需要使用特殊参数 “$@” 来传递命令的后续参数 手动编写一个wrapper.sh,包含如下内容 #! /bin/bash cd /some/work/dir source /some/virtualenv/dir/bin/activate “$@” 测试使用 #bash /some/work/dir/wrapper.sh python xxx.py #crontab */5 8-20 * * * /some/work/dir/wrapper.sh python xxx.py
Nginx开启Basic_Auth登录认证
Nginx支持直接开启basic auth,开启Basic_Auth登录后客户端需要在请求头部添加Basic_Auth的内容方可继续访问 在nginx配置文件的server段添加以下 server { #…… auth_basic “XXXX”; #提示登录文本 auth_basic_user_file conf/htpasswd; #密码文件路径 #…… } 两种方式生成basic auth的密码 使用openssl printf “username:$(openssl passwd -crypt 123456)\n” >>conf/htpasswd 使用htpasswd #创建 htpasswd -c -d conf/htpasswd username #修改 htpasswd -b -d conf/htpasswd username passwd
使用dsadd批量添加AD域用户
将需要导入的用户以csv格式组织 姓 名 全名 登录名 密码 张,三, 张三, three.zhang,pass01 李,四, 李四, four.li, passo2 王,五, 王五, five.wang, pass03 刘,六, 刘六, six.liu, passo4 赵,七, 赵七, seven.zhao, pass05 执行脚本,使用dsadd 添加域用户 for /f “tokens=1,2,3,4,5 delims=,” %a in (users.csv) do dsadd user “cn=%c,ou=cosmos.com,dc=cosmos,dc=com” -samid %d -upn %[email protected] -fn %b -ln %a -pwd %e -disabled no 中途注意检查重名,否则导入失败
DIR命令无法获得精确到秒的问题
DIR命令无法获得精确到秒的问题 方法一,dir命令只能到分钟,如果需要到秒,建议改用forfiles命令 REM “delims=” is required to avoid stripping AM/PM for /f “delims=” %%i in (‘”forfiles /p C:\Users\limc /m *.bat /c “cmd /c echo @fdate @ftime” “‘) do set modif_time=%%i echo %modif_time% 参考 https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/cc753551(v=ws.11)?redirectedfrom=MSDN 方法二,用VBS的FileSystemObject方式解决 @set @n=0/*&echo off dir /a-d/s/b|Cscript -nologo -e:jscript “%~f0” > 1.txt pause&exit /b */ var fso=new ActiveXObject(‘scripting.FileSystemObject’); while(!WSH.StdIn.AtEndOfStream) { file=fso.GetFile(WSH.StdIn.ReadLine()); t=new …
nginx 首页不存在时默认返回404而不是403
nginx 首页不存在时默认返回404而不是403 域名被某站劫持了导致整站被B,通过nginx设置将指定域名bound到指定的站点,然后强制返回404。 location = / { return 404; } 但是首页还是返回403代码。而不是预期的404。 于是让404正常,再直接把首页301 到一个不存在的资源。 完工 location = / { index index.html return 404; } location = /index.html { return 301 /noexsit; }
windows计划任务指定时间段执行程序
一个简单的需求,windows服务器设置计划任务,在需要在指定时间段9点到15点执行特定的程序。 但是windows的计划任务不像corntab那样支持设定指定时间区间,只可以设置每小时启动一次。 方法1.启动Bootstrap程序,根据当前时间决定是否继续执行任务 获取当前时间的字符串 SET curr_time=%TIME:~0,-5% SET curr_time_str=%curr_time::=% 获取时间后,逻辑判断是否goto执行相应的代码 完整的代码 @echo off ECHO “Time Schedule Bootstrap” SET curr_time=%TIME:~0,-5% SET curr_time_str=%curr_time::=% IF %curr_time_str% leq 0900 (GOTO time_cancel) ELSE ( IF %curr_time_str% leq 1500 (GOTO time_exec) ELSE ( GOTO time_cancel ) ) exit 0 :time_exec ECHO “Call CMD.exe” CMD.exe exit 0 :time_cancel ECHO “Canceled” exit 10 方法2.设置每天启动一次在指定的小时,需要设置多次,此处跳过