SFTP file delete

The machine enters a strange error state, when I remotely delete the current active NC file from \sysroot\home\pocketnc\ncfiles\

What do you mean by strange error state? Kinetic Control is intended to be used through the UI, so there can be side effects if you bypass that workflow.

Strange error means, that sometimes I even have to reboot the machine to recover from this state.
In general I wonder, why it’s relevant, that the NC file exists on the disk, when already “loaded” to memory and why the file is not locked? On the other hand, If it is really necessary to keep the active file on disk, how can I remotely “deactivate/unload” this file?

Files aren’t necessarily read entirely into memory, especially large files. The UI also runs on a separate computer so to avoid having to transfer files unnecessarily, checksums are cached on every file. The checksum process can take a long time, so this process is only performed on file upload and results are cached, which can result in side effects when deleting files in an unsupported way. What happens when you open a different file? Uploading a file with the same name through the UI would also force the checksum to be recalculated.

Ok. Is there a way to remotely initiate a file open or an “unload file”?
If I open a different file - before I delete the other one from disk - then it works.

You could connect like the UI does to the websocket on port 8000. Here’s an example Python program.
unload.py (1.1 KB)