Jenkins+Ansible+Gitlab 自动化部署实战视频教程

需要学习资源,请点击开挂教学楼

需要学习资源,请点击开挂教学楼

我有一个PowerShell脚本,我正在编写,我需要保留当月的每日备份,一年中的月末备份,并删除除此之外的任何内容。

 
  1. $ThisYear = (Get-Date).year

  2. $DailyLogs = (Get-Date).month

  3.  
  4. #Clean-Up Old Backup Files

  5. Get-ChildItem 'D:\' | ForEach-Object {

  6. if ( $_.LastWriteTime.Year -gt $ThisYear) {

  7. Remove-Item

  8. }

  9. Elsif ( $_.LastWriteTime.Month -gt $ThisMonth -and $_.LastWriteTime.Date -ne ) {

    扫描二维码关注公众号,回复: 5741608 查看本文章
  10. Remove-Item

  11. }

到目前为止,这应该删除任何不是当前年份的备份文件。我试图解决的问题是如何删除除当前月份之后每个月末的备份文件以外的每日备份。我被困在如何获得-ne到任何给定月份的最后一天。

  1. #Clean-Up Old Backup Files

  2. Get-ChildItem 'D:\Server Backup\' | ForEach-Object {

  3. if ( $_.LastWriteTime.Year -gt $ThisYear) {

  4. Remove-Item

  5. }

  6. Elsif ( $_.LastWriteTime.Month -gt $ThisMonth -and $_.LastWriteTime.Date -ne [System.DateTime]::DaysInMonth($_.LastWriteTime.Year, $($_.LastWriteTime.Month))) {

  7. Remove-Item

  8. }

  9. }

基于Lee的评论,这是我的想法。

我用一个  draw 函数在图像中绘制一个矩形。

 
  1. def draw(image, location):

  2. ...

  3. cv2.rectangle(image, ...)

  4. return image

由于有很多  locations 矩形,我使用该  map 函数绘制那些矩形。

list(map(lambda x: draw(image, x), locations))

但是,该功能是串行执行的。这意味着速度非常慢。有没有办法在同一图像上平行绘制矩形?

$ThisYear = (Get-Date).year
$DailyLogs = (Get-Date).month

#Clean-Up Old Backup Files
Get-ChildItem 'D:\' | ForEach-Object {
    if ( $_.LastWriteTime.Year -gt $ThisYear) {
        Remove-Item
    }
    Elsif ( $_.LastWriteTime.Month -gt $ThisMonth -and $_.LastWriteTime.Date -ne ) {
        Remove-Item
    }
#Clean-Up Old Backup Files
Get-ChildItem 'D:\Server Backup\' | ForEach-Object {
    if ( $_.LastWriteTime.Year -gt $ThisYear) {
        Remove-Item
    }
    Elsif ( $_.LastWriteTime.Month -gt $ThisMonth -and $_.LastWriteTime.Date -ne [System.DateTime]::DaysInMonth($_.LastWriteTime.Year, $($_.LastWriteTime.Month))) {
        Remove-Item
    }
}
def draw(image, location):
    ...
    cv2.rectangle(image, ...)
    return image
list(map(lambda x: draw(image, x), locations))

猜你喜欢

转载自blog.csdn.net/qq_31642819/article/details/88700093