当前位置:首页 > linux运维

宝塔shell脚本删除日期生成的目录

14324472931年前 (2025-02-21)linux运维1380
#!/bin/bash

# 定义要查找的目录路径
TARGET_DIR="/www/xxxxxx/public/tempipg"

find "$TARGET_DIR" -type d -mtime +3 | grep -E "${TARGET_DIR}/[0-9]{8}$" | while read -r dir; do
    dirname_part="${dir##*/}"  # 提取目录名的最后一部分(这里应该是日期)
    parent_dir="${dir%/${dirname_part}}"  # 提取父目录路径(用于验证完整性,可选)
    echo "Full path: $dir"
    rm -rf "$dir"
done

扫描二维码推送至手机访问。

版权声明:本文由爱开发博客发布,如需转载请注明出处。

本文链接:https://www.lovekf.cn/?id=37

分享给朋友:

“宝塔shell脚本删除日期生成的目录” 的相关文章

openvpn服务端一键搭建

需求: 搭建openvpn目的是安全访问内网和匿名访问其他网站,确保隐私信息不会泄露。 搭建方法: 1.复制以下脚本命名为“openvpn-install.sh”,在ssh中执行。 ```bash#!/bin/bash shellcheck disable=SC1091,SC2164,SC…

aria2配置文件和bt-tracker定期更新脚本

# # https://github.com/P3TERX/aria2.conf # File name:aria2.conf # Description: Awesome Aria2 configuration file # Version: 2021.09.15 # # Copyright (c…

linux基线配置脚本(自己更具需求书写,并不适合所有人)

支持内容:1.检查更新系统时间。 ```bash#!/bin/bash 更新系统时间(假设你有NTP服务或者可以访问互联网时间服务器)echo “Updating system time using NTP…”sudo timedatectl set-ntp true 检查是否成功设置…

使用自定义docker加速地址下载镜像

1.例如加速地址为:https://docker.1ms.run2.配置docker加速地址cat > /etc/docker/daemon.json <<EOF > {"registry-mirrors":&nb…

linux宽带速度测试

```bashwget -O /dev/null http://speed.hetzner.de/100MB.bin –progress=bar:force https://nbg1-speed.hetzner.com(德国纽伦堡) https://fsn1-speed.hetzner.com(…

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。