S3 Bash 脚本循环
我编写了一个脚本来获取 S3 存储的大小,该脚本运行良好,除非它不断循环且永不结束。我得到了我需要的所有输出,但它不断地遍历它们。
关于为什么它循环有什么想法吗?
#!/bin/sh
DAY=$(date +"%d%b%Y")
BUCKET='/home/user/Scripts/Holding/s3buckets.txt'
BLIST='/home/user/Scripts/Holding/blist.txt'
LOGDIR='/home/user/Scripts/Holding/'
USAGE=$BLIST
s3cmd ls > $BUCKET
awk '{print $3}' $BUCKET > $BLIST
while read USAGE; do
s3cmd du -H $USAGE
done < $BUCKET > $LOGDIR/S3Usage$DAY.txt
I've written a script to get the size of my S3 storage, the script works fine barring the fact that it keeps looping and never ends. I get all the outputs as I need but it keeps going through them.
Any ideas on why its looping?
#!/bin/sh
DAY=$(date +"%d%b%Y")
BUCKET='/home/user/Scripts/Holding/s3buckets.txt'
BLIST='/home/user/Scripts/Holding/blist.txt'
LOGDIR='/home/user/Scripts/Holding/'
USAGE=$BLIST
s3cmd ls > $BUCKET
awk '{print $3}' $BUCKET > $BLIST
while read USAGE; do
s3cmd du -H $USAGE
done < $BUCKET > $LOGDIR/S3Usage$DAY.txt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
s3cmd du -H $USAGE
更改为s3cmd du -H s3://$USAGE
不带
s3://, s3cmd 默认提供所有存储桶的列表。我敢打赌
s3buckets.txt
只有存储桶名称,而不是协议前缀。Change
s3cmd du -H $USAGE
tos3cmd du -H s3://$USAGE
Without the
s3://
, s3cmd defaults to giving the listing for all buckets. I'm betting thats3buckets.txt
just has the bucket names, not the protocol prefix.