2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

S3バケットの最終更新日を知る方法

Posted at

ふとネタを思いついたので書く。

S3の各バケットの最終更新日を知る必要が出てきたのだが、コンソール画面からは確認できないらしい。

そこでバケット内の一番新しいオブジェクトの最終更新日を表示させるスクリプトを書いた。

#!/bin/sh
buckets=(
  "bucket_1"
  "bucket_2"
  "bucket_3"
)

for bucket in ${buckets[@]}
do
    LASTMODDATE=$(/usr/local/bin/aws s3 ls $bucket --recursive | sort | tail -n 1 | cut -d ' ' -f1,2)
    echo "$bucket : $LASTMODDATE"
done

bucketsにバケット名の指定を自分でする。

雑だけどとりあえずの目的は満たせているのでOK。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?