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 …
Monthly Archives: July 2021
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.设置每天启动一次在指定的小时,需要设置多次,此处跳过
[WordPress] 子目录下WP建站Nginx反向代理设置
子目录下WP建站Nginx反向代理设置 参考官方文档,两种方式一下都可以实现要求 方法1,rewrite方式,适用php-fpm location /替换子目录名称/ { index index.html index.php; if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite (.*) /替换子目录名称/index.php; } } 方法2,使用try_files方式 location /替换子目录名称/ { index index.php; try_files $uri $uri/ /替换子目录名称/index.php?$args; } 必须要做的,把wp-admin单独处理 rewrite /替换子目录名称/wp-admin$ $scheme://$host$uri/ permanent;