我有一个脚本可以将文件从目录上传到S3存储桶。
我的剧本是这样的
aws s3 sync <directory_of_files_to_upload> s3://<bucket-name>/
当我运行这个脚本时,整个文件被正确上传。
每当上载新文件时,我都要运行此脚本,因此我决定使用inotify
我的剧本是这样的
#!/bin/bash
inotifywait -m -r -e create "<directory_of_files_to_upload>" | while read NEWFILE
do
aws s3 sync sunshine s3://turnaround-sunshine/
done
我的问题是双重的
1.当我运行此脚本时,它将接管终端,因此我无法执行其他操作。
[ec2-user@ip-xxx-xx-xx-xx s3fs-fuse]$ ./Script.sh
Setting up watches. Beware: since -r was given, this may take a while!
Watches established.
-
它在我从本地上载文件时运行,但不上载整个文件。EC2中的文件为2.7MB,但S3中只有约350KB。当我自己运行aws命令而不使用inotify时,它可以正常工作(整个文件都会上传)。当我将文件上传到监控目录时,程序也会输出(如下)。
上传:sunshine/turnaroundtest.json至s3://turnaturn sunshine/turnaroundtest.json