내용으로 건너뛰기

fs.statSync() isn't giving actual BirthTime of the EFS file

1

I am using fs (Node Module) to manage files. I am getting the file's created time (BirthTime). It is working absolutely fine when I run this app on my local machine. But when I try to implement it on EFS using NodeJs Lambda function then it gives 1970-01-01T00:00:00.000Z which is not the actual time of the file that I created.

var efsDirectory = "/mnt/data/";
var filePath = path.join(efsDirectory, file);
console.log("This file is going to be executed :", file);
var response = fs.statSync(filePath);
let fileBirthTime = response.birthtime;
console.log("File path is : ", filePath);

After joining the path my filepath looks like this filepath = /mnt/data/172.807056.json which is the actual path of the file.

In the Cloudwatch logs I am getting this : Cloudwatch Logs

On the local machine, it is working fine and giving the actual file birthtime. Can you tell me guys why I am getting this? All other values like ctime, atime, mtime are created properly except birthtime? This behavior is only when I play with files on EFS.

1개 답변
0
수락된 답변

You are getting this result with birthtime, as it is not supported on most NFS filesystems like EFS. Even on Linux OSes it depends on the kernel and type of file system as to whether this field is supported. The default file system on Amazon Linux 2 on EBS doesn't return a value to birthtime. However with the latest Ubuntu image, it is supported. This is why you would be seeing a difference between running it locally and against EFS.

AWS
답변함 3년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.