Below is a Bash script that will query a bucket with the current date specified on the system. Querying or listing the contents of the S3 bucket is quite a good strategy. Let's say if you need to make sure that important backups are copied or present on S3 bucket. Or you need to monitor what are the contents being dumped to a specific S3 bucket. Automating querying S3 contents in Linux using Bash scripting is a good idea. Below is a code that works fine on a Linux system. #!/bin/bash varDate=$(date +%Y-%m-%d) aws s3api list-objects --bucket "name_of-the-bucket" --prefix sub_directory_bucket --query 'Contents[?LastModified>=`'${varDate}'`][].{Key: Key, Size: Size, LastModified: LastModified}' >> /tmp/s3_server_files_$varDate.txt The script can be configured on a cron task and runs on a daily basis then the date is automatically supplied by the bash script and data is saved on /tmp/ and file will not be overwritten since filename is based on date. ...
Make the world a better place by sharing knowledge, ideas and anything that you can give that comes from the heart.