#!/bin/bash input_dir="/path/to/input/dir"

while true; do current_time=$(date +%s) for file in $input_dir/*; do if [ -f "$file" ]; then file_time=$(stat -c %Y "$file") time_diff=$((current_time - file_time)) if [ $time_diff -gt 3600 ]; then rm "$file" fi fi done sleep 60 done

用shell写一个脚本监视一个输入目录删除出现超过一个小时的文件文件时间按照每次遍历时的时间计算

原文地址: https://www.cveoy.top/t/topic/fnQw 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录