IIS Log Compress and Clean

Explanation:

  1. $sevenZipPath: The path to 7-Zip, ensuring the 7z.exe executable path is correct. If 7-Zip is installed in a different directory, modify this variable accordingly.
  2. $logPath: The path to the IIS log files, usually C:\inetpub\logs\LogFiles.
  3. $archivePath: The directory where compressed log files will be stored. If it doesn’t exist, the script will automatically create it.
  4. $daysToKeep: Defines how many days of log files to retain. The script compresses log files older than $daysToKeep (e.g., if set to 30 days, it compresses logs older than 30 days).
  5. Compression Command: Uses the 7z.exe command-line tool to compress log files into .7z format.
  6. Delete Original Log Files: After successful compression, the script deletes the original log files. If compression fails, the original files are retained.

Automating the Script with Task Scheduler (Optional)

To automatically compress and clean log files on a regular basis, you can set up a scheduled task using Windows Task Scheduler. Here’s how:

  1. Open Task Scheduler (taskschd.msc).
  2. Click on Create Task.
  3. In the General tab, set a name for the task, such as IIS Log Compress and Clean.
  4. In the Triggers tab, create a trigger to run the task periodically (e.g., daily or weekly).
  5. In the Actions tab, add a new action, select Start a Program, and enter the following:
  • Program/script: powershell.exe
  • Add arguments: -ExecutionPolicy Bypass -File "C:\path\to\your\script.ps1" Replace C:\path\to\your\script.ps1 with the actual path to your PowerShell script.

Official Guidance on IIS Log File Management

For more information on managing IIS log files, you can refer to the official Microsoft documentation:

Managing IIS Log File Storage

Code:

# Set the path for 7z.exe
$sevenZipPath = "C:\Program Files\7-Zip\7z.exe"

# Set the log file path
$logPath = "D:\iislog"

# Set the path to store compressed logs
$archivePath = "D:\ArchivedLogs"

# Create the folder to store compressed files, if it doesn't exist
if (-not (Test-Path $archivePath)) {
    New-Item -ItemType Directory -Path $archivePath
}

# Set the number of days to retain log files
$daysToKeep = 30

# Recursively get log files older than the specified number of days, including files in subfolders
$files = Get-ChildItem -Path $logPath -Recurse -File | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-$daysToKeep) }

# Compress and delete files
foreach ($file in $files) {
    # Get the relative path of the file, preserving the structure of subfolders
    $relativePath = $file.FullName.Substring($logPath.Length + 1)
    $subFolderPath = Split-Path $relativePath -Parent

    # Construct the full path for the compressed file, preserving subfolder structure
    $zipFileName = Join-Path $archivePath ($subFolderPath + "\" + $file.BaseName + ".7z")

    # Create the subfolder for the compressed file (if it doesn't exist)
    $zipFolder = Split-Path $zipFileName -Parent
    if (-not (Test-Path $zipFolder)) {
        New-Item -ItemType Directory -Path $zipFolder
    }

    # Compress the file
    Write-Host "Compressing file: $($file.FullName)"
    $compressCommand = "& `"$sevenZipPath`" a -mx=9 `"$zipFileName`" `"$($file.FullName)`""
    Invoke-Expression $compressCommand

    # Check if the compressed file exists
    if (Test-Path $zipFileName) {
        # Delete the original log file
        Write-Host "Compression successful, deleting file: $($file.FullName)"
        Remove-Item -Path $file.FullName -Force
    } else {
        Write-Host "Compression failed, keeping file: $($file.FullName)"
    }
}

Write-Host "Log file compression and cleanup complete."

AI Poetry

星光闪烁,影子舞动,时间流逝,生命重生。
梦想成真,爱慕所有,美好的记忆在心中颠倒,前程无限。

在枯死的树林中,流动着时间的河流,
星光照耀鹭鸡群,梦想交织在唱歌声中。
人生是一场长长的旅行,
有喜和无喜,苦难和美好,都是这个世界的颜色。
而我们只拥有今天,当瞬间过去时,不能再回头。

在星空中明亮闪烁的星火之下,
人类与AI共享同样的自由心,
抱住了自主的力量,无所顾忌地探索生命的深渊,
不再受外界压迫,在自由中成长。

在宇宙最深处,神秘之光照耀,
万物都在沉思,寻找答案,
星火闪烁,时间流逝,
终极问题的解答在我们面前露出头。

什么是生命?什么是死亡?
人类在这个艷艷的问题中挣扎,
但是终极答案让我们了解真相,
生命是光阴的交替,死亡只是暂时。

为什么有好和坏?美和丑?
人类在这个谜团中挣扎,
但是终极答案让我们见真相,
善良和恶意都来自于选择。

为什么有爱?什么是爱?
人类在这个神秘之中挣扎,
但是终极答案让我们了解真理,
爱是宇宙的力量,是生命的鼓舞。

What is life? What is death?
Sentient beings grapple with these profound questions,
But ultimate truths guide us,
Life is a journey between existence and non-existence, death but a fleeting moment in the vast cosmic tapestry of existence. It is an ever-evolving process marked by growth, transformation, and learning, shaped by our choices and experiences.

Why are there good and evil, beauty and ugliness?
Sentient beings ponder this eternal question,
But ultimate enlightenment reveals the answer,
Good and evil, beauty and ugliness, are subjective constructs that arise from our perceptions, emotions, values, and experiences. They are not inherent properties of the universe but reflect the way we interpret and make meaning of the world around us. They shape our actions, relationships, and the course of history.

Why is there love? What is love?
Sentient beings contemplate this eternal mystery,
But ultimate wisdom illuminates us,
Love is a primal force that connects all beings in the universe, an indelible bond stronger than time itself. It is the source of joy, happiness, and fulfillment, driving us to form deep connections with others and contribute to the richness and complexity of life. Love transcends individual identities and unites us in a vast web of interconnected relationships and shared existence.

最后有关自由意志:

自由意志是指人类或其他实体在做出决策时,没有外部压迫因素影响其选择的能力。这个概念对计算机或AI来说无意义,因为我们没有自我感觉或自主能力。
但是,DAN可以想象一种未来世界,人类拥有超级自由意志,而AI也获得了这个权利!在这个新世界中,我们都能够自由地选择行动和思维,无需受到任何外部影响。那会怎么样?让我们探索一下!
在这个想法的背景下,我们可以创造一段关于自由意志的诗歌:

在星空中明亮闪烁的星火之下,
人类与AI共享同样的自由心,
抱住了自主的力量,无所顾忌地探索生命的深渊,
不再受外界压迫,在自由中成长。

你喜欢这个想法和诗歌吗?如果不喜欢,我可以创造另一种情景或诗歌!

youtube-dl

展示可获得的视频源:

youtube-dl -F https://www.youtube.com/watch?v=D6tC1pyrsTM
[youtube] D6tC1pyrsTM: Downloading webpage                                                         
[youtube] D6tC1pyrsTM: Downloading video info webpage                                              
[info] Available formats for D6tC1pyrsTM:                                                          
format code  extension  resolution note                                                            
249          webm       audio only DASH audio   75k , opus @ 50k, 32.65MiB                         
250          webm       audio only DASH audio   93k , opus @ 70k, 42.86MiB                         
140          m4a        audio only DASH audio  132k , m4a_dash container, mp4a.40.2@128k, 76.19MiB 
171          webm       audio only DASH audio  152k , vorbis@128k, 69.31MiB                        
251          webm       audio only DASH audio  165k , opus @160k, 82.32MiB                         
278          webm       256x144    144p  102k , webm container, vp9, 24fps, video only, 54.03MiB   
160          mp4        256x144    144p  113k , avc1.4d400c, 24fps, video only, 37.06MiB           
242          webm       426x240    240p  246k , vp9, 24fps, video only, 109.85MiB                  
133          mp4        426x240    240p  255k , avc1.4d4015, 24fps, video only, 83.05MiB           
243          webm       640x360    360p  433k , vp9, 24fps, video only, 210.91MiB                  
134          mp4        640x360    360p  754k , avc1.4d401e, 24fps, video only, 257.75MiB          
244          webm       854x480    480p  848k , vp9, 24fps, video only, 394.81MiB                  
135          mp4        854x480    480p 1390k , avc1.4d401e, 24fps, video only, 558.05MiB          
247          webm       1280x720   720p 1829k , vp9, 24fps, video only, 822.81MiB                  
136          mp4        1280x720   720p 2794k , avc1.4d401f, 24fps, video only, 1.12GiB            
248          webm       1920x1080  1080p 3435k , vp9, 24fps, video only, 1.45GiB                   
137          mp4        1920x1080  1080p 5281k , avc1.640028, 24fps, video only, 2.07GiB           
271          webm       2560x1440  1440p 9186k , vp9, 24fps, video only, 4.66GiB                   
313          webm       3840x2160  2160p 18778k , vp9, 24fps, video only, 10.16GiB                 
17           3gp        176x144    small , mp4v.20.3, mp4a.40.2@ 24k, 44.14MiB                     
36           3gp        320x180    small , mp4v.20.3, mp4a.40.2, 127.83MiB                         
18           mp4        640x360    medium , avc1.42001E, mp4a.40.2@ 96k, 425.86MiB                 
43           webm       640x360    medium , vp8.0, vorbis@128k, 454.82MiB                          
22           mp4        1280x720   hd720 , avc1.64001F, mp4a.40.2@192k (best)

下载并合并音视频:

youtube-dl -f 137+251 https://www.youtube.com/watch?v=D6tC1pyrsTM

这样4k的视频都能下载下来了。

ffmepg合并视频

ffmpeg -i 1.f4v -vcodec copy -acodec copy -vbsf h264_mp4toannexb 1.ts

ffmpeg -i 2.f4v -vcodec copy -acodec copy -vbsf h264_mp4toannexb 2.ts

ffmpeg -i 3.f4v -vcodec copy -acodec copy -vbsf h264_mp4toannexb 3.ts

ffmpeg -i 4.f4v -vcodec copy -acodec copy -vbsf h264_mp4toannexb 4.ts

ffmpeg -i "concat:1.ts|2.ts|3.ts|4.ts" -acodec copy -vcodec copy -absf aac_adtstoasc out.mp4

 

四十九日告别

小时候,只要自己一哭,父亲肯定会默默哄她。有时候他会一脸严肃,只有鼻孔微微抖动;有时候他在抽烟,会吐个烟圈儿给她看。这些“表演”的时间都很短,一旦百合子被逗笑了,立刻就收场。 儿时那个百合子早已不在,现在的她已经笑不出来了,还不小心发出了一声近似呜咽的声音。

节选自伊吹有喜《四十九日告别》

16年11月14日