【发布时间】:2018-10-16 15:16:10
【问题描述】:
我有一个文件系统,可以在其中将文件拖放到 EC2 实例中,并且我运行了一个 shell 脚本以将新删除的文件同步到 s3 存储桶。我希望在同步后从 E2C 实例中删除文件。具体来说,文件被放入“yyyyy”文件夹中。
下面是我的shell代码:
#!/bin/bash
inotifywait -m -r -e create "yyyyy" | while read -r NEWFILE
do
if lsof | grep "$NEWFILE" ; then
echo "$NEWFILE";
else
sleep 15
aws s3 sync yyyyy s3://xxxxxx-xxxxxx/
fi
【问题讨论】:
-
您能解释一下为什么在同步后不使用
rm或aws s3 mv吗? -
我将捕获“aws s3 sync yyyyy s3://xxxxxx-xxxxxx/”行的结果作为变量,并确认返回代码表明同步成功。然后编写一个 if 成功例程来 rm 文件)。
标签: linux bash shell amazon-web-services amazon-ec2