Saltar al contenido

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 Respuesta
0
Respuesta aceptada

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
respondido hace 3 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.