liujia 发布的文章

为从网页复制的域名列表设置子域名

需求:从网页复制到域名列表,需要设置1.aa.com, 2.aa.com,3.aa.com的子域名。

尝试:可以使用while的条件执行语句来操作,如:

sed 's/  //g' do2.txt | while read -r line; do for chi in $(seq 1 3); do echo -e "$chi.$line"; done done

参考:

为IP地址列表打乱排序 - shuf - sed - sort

需求:一个有超过10个的IP地址的文本文件,需要打乱IP地址原有的排序。

尝试:

在Linux系统里,较方便的命令是 shuf。如果在Windows里没有这个命令,但有如 mobaXterm 的 Cygwin 和 Busybox 环境,可用sed、sort和cat命令来组合使用,达到类似的效果。如:

cat ip.txt | while read -r line; do echo "$RANDOM:$line"; done | sort -t: -k1 -n | sed 's/^[0-9]*://' > n.txt

参考:

magento - 磁盘用满 - /tmp/analytics - Advanced Reporting

现象:magento2的站点,在几天后,站点访问不了,提示磁盘用满。检查后,发现 /tmp/analytics 目录下的文件占了绝大多数。

尝试:按照 magento2 的更新记录,将文件 vendor/magento/framework/Archive/Tar.php 约第262行的内容替换,

array_shift($dirFiles);
/* remove  './'*/
array_shift($dirFiles);
/* remove  '../'*/

替换为:

$dirFiles = array_diff($dirFiles, ['..', '.']);

magento-advanced-reporting-disk-full.png

参考:https://magento.stackexchange.com/questions/243746/disk-space-issue-with-advanced-reporting-after-update-from-2-2-3-to-2-2-6

nextcloud 上传10GB文件后,提示组块时出错 502 - nginx 超时限制设置

现象:nextcloud 需要上传超过10GB的文件,但上传完成后“组块时出错 502”。nginx 的web错误信息里有如:

recv() failed (104: Connection reset by peer) while reading response header from upstream request: "MOVE /remote.php/dav/uploads/name/web-file-upload-nnnn/.file" HTTP/1.1, upstream: fastcgi://unix:/tmp/php-cgi-72.sock

nextcloud-big-file-502-1.png

查看 php-fpm.log 的日志,如:

WARNING: [pool www] child nnnn, script '/www/wwwroot/nextcloud/remote.php'(request: "MOVE /remote.php") execution timed out (104.723765 sec). Terminating.
WARNING: [pool www] child nnnn exited on signal 15 (SIGTERM) after 13101.403079 seconds from start

nextcloud-big-file-502-2.png

估计是 php-fpm 的进程在约100秒后超时,被强制退出,然后重新创建进程了。

解决:在“宝塔”面板的php7.2管理配置窗口中,将“超时限制”(request_terminate_timeout)的时间上调,如从默认100秒的,上调到17200。

nextcloud-big-file-502-4.png

参考:

为远程桌面连接设置邮件提醒

需求:远程桌面连接Windows 2012时,会收到邮件提醒,提醒内容包含登录者的IP信息。

1.创建一个vbs脚本,能通过外部的smtp服务器发出邮件的

2.创建一个“定时任务”,条件是用户登录时运行,运行上边创建好的vbs脚本

3.如果通知内容还需带上远程桌面登录者的IP,可以在vbs脚本上加上提取IP的内容

例子:

set sh = CreateObject("Wscript.Shell") 
set Connections = CreateObject("Scripting.Dictionary") 

call Main() 

Function Main() 
    call GetConnections() 
    call ProcessConnections() 
End Function 

Function GetConnections() 
    i = 0 
    set shExec = sh.Exec("netstat -f") 

    Do While Not shExec.StdOut.AtEndOfStream 
        Line = shExec.StdOut.ReadLine() 
        If Instr(Line, "TCP") <> 0 Then 
            Set Connection = New NetworkConnection 
            Connection.ParseText(Line) 
            call Connections.Add(i, Connection) 
            i = i + 1 
        End If 
    Loop 
End Function 

Function ProcessConnections() 
    For Each ConnectionID in Connections.Keys 
        'wscript.echo ConnectionID & Connections(ConnectionID).RemoteIP
    Next 
End Function 

Class NetworkConnection 
    Public Protocol 
    Public LocalIP 
    Public LocalPort 
    Public RemoteIP 
    Public RemotePort 

    Public Sub ParseText(Line) 
        dim i 

        For i = 5 to 2 Step -1 
            Line = Replace(Line, String(i, " "), " ") 
        Next 

        Line = Replace(Line, ":", " ") 
        Line = Right(Line, Len(Line) - 1) 
        Line = Split(Line, " ") 

        Protocol = Line(0) 
        LocalIP = Line(1) 
        LocalPort = Line(2) 
        RemoteIP = Line(3) 
        RemotePort = Line(4) 

    End Sub 

    Private Sub Class_Initialize 
        'MsgBox "Initialized NetworkConnection object" 
    End Sub 

End Class

NameSpace = "http://schemas.microsoft.com/cdo/configuration/" 
Set Email = CreateObject("CDO.Message") 
Email.From = "18900000000@189.cn" 
Email.To = "18900000000@189.cn" 
Email.Subject = "有人登陆服务器 - " & ConnectionID & Connections(ConnectionID).RemoteIP
Email.Textbody = "注意检查登陆者是否合法!" 
With Email.Configuration.Fields 
.Item(NameSpace&"sendusing") = 2 
.Item(NameSpace&"smtpserver") = "smtp.189.cn" 
.Item(NameSpace&"smtpserverport") = 25 
.Item(NameSpace&"smtpauthenticate") = 1 
.Item(NameSpace&"sendusername") = "18900000000" 
.Item(NameSpace&"sendpassword") = "youxiangmima" 
.Update 
End With 
Email.Send

参考: