I need assistance with the exec node

Hi, I'm running Node-RED on Windows and using the "exec" node with the following command to get .jpg file modification details:

stat -c "%z %s %n" --

Here's the issue I'm facing:

  • In the first iteration, I modify one .jpg file using Microsoft Paint, save it, and then run the command. The output from the exec node correctly shows the updated timestamp, which matches the file’s "Date Modified" in Windows file properties.
  • In the second iteration, I modify a different .jpg file and run the command again. The output now shows the correct updated timestamp for the newly modified file — but strangely, the timestamp for the first file also changes, even though I didn’t modify it.
  • What’s more unusual is that the first file’s new timestamp is about 2 seconds earlier than the second (actually modified) file.
  • This new timestamp for the first file does not match what's shown in Windows file properties (it still shows the original modification time there).

Hi and welcome to the forum.

The stat command is a Linux command rather than Windows, can you perhaps explain a little more about your configuration and where things are running?

The node red is running on rancher desktop.

Sorry but I've no idea what "rancher desktop" is.

Rancher basically provides Kubernetes and container management environment on our local system.

I guess running linux command is not a problem as we have installed Windows Subsystem for Linux (WSL). So, we didn't face any issue in running 'stat'.

OK, so you still haven't actually described your configuration and I can't help without more info.

Right, now we have a little more info but I still don't know how you are actually running things.

Are you saying that you have Windows running in a container which, in turn is running WSL? Where is Node-RED running?

Yes you are right..

OK, well, that is a slightly mad setup! Why not simply run Linux in a container? Would be vastly more performant and a lot simpler to manage.

This feels like a caching issue but very hard to say given the complex environment. And WSL is not meant to be used for live environments either.

And you still haven't told me where Node-RED is running? On the host, in the Windows container or in the WSL container in the Windows container?

ok let me try to answer this... as per my understanding node red is running on a container management system on local machine called "rancher desktop" & infact rancher desktop is running on WSL container in window OS.

I'm sorry but that doesn't really make sense.

The "rancher desktop" is a container manager that runs on a host OS. Node-RED is a node.js app (code that is executed by the node.js application) which requires an OS to run under. WSL is a Linux environment that runs under a Windows OS.

  • Host OS (Windows?) - Is Node-RED/node.js running here?
    • --> Rancher Desktop (container manager)
      • --> Containerised OS (Windows?) - Or is Node-RED/node.js running here?
        • --> WSL (lightweight Linux container) - or is Node-RED running here?

In addition to knowing where Node-RED is running, which OS (the host, the container or WSL) is hosting the image files?

If at all possible, please try to simplify your architecture because you have at least 1 or 2 too many layers which is making things far too complex and is most likely the root cause of your issues.

Almost certainly not really a Node-RED issue by the way.

1 Like

Are you working on your own personal computer or a company/college one?

By the way, we've not even got into better ways to get the file info. Node.js has its own libraries which will likely be a lot more effective. They can be used with a function node.

But until we know how your setup is actually structured, we still can't really help.

1 Like