首页 > 解决方案 > 用于检查文件准确性的 shell 脚本

问题描述

我有脚本可以检查删除了多少桶的准确性。我想要编写一个脚本,一旦上述脚本停止运行,它就可以帮助我,它必须再次检查文件并且有任何剩余的存储桶创建一个输入列表并在其余存储桶上运行第二个“rm -rf”然后重复自身直到他们都走了。请在下面找到脚本:

#!/bin/bash

rm /tmp/buckets_to_remove/*

# Ensure that the /tmp/buckets_to_remove directory exists and if not then create it
if [ ! -d /tmp/buckets_to_remove ]
 then
  mkdir /tmp/buckets_to_remove
fi

please find the error below:
Removing bucket act/1473823073_1459448859_XXXXX
Removing bucket act/1453904759_1438082433_XXXXX
Removing bucket act/1477122647_1442503432_XXXXX
Removing bucket asa/1473740503_1472875269_XXXXX
Removing bucket asa/1473741465_1473740502_XXXXX
Removing bucket asa/1473740504_1473740502_XXXXX

标签: linuxbashshellsh

解决方案


这是你想要的?

rm命令将每 15 秒连续运行一次。

#!/bin/bash
# Ensure that the /tmp/buckets_to_remove directory exists and if not then create it
if [ ! -d /tmp/buckets_to_remove ]
    then
    mkdir /tmp/buckets_to_remove
fi

while(true)
    do
        for rmbuckets in $( ( ls /tmp/buckets_to_remove/ ) )
        do
            rm "$rmbuckets"
        done
    sleep 15
    done

推荐阅读