DELETE ALL FILES FROM /home/dev/unsecured/

Hi, I need delete all the files in Epic unsecured directory. Do you have any idea to deleting files all at a time?

Thanks for ideas and help

Rodrigo

PD: I try node-red-contrib-fs-ops but dont works

Do you have shell access?

EDIT. Do you want to do this through Node-RED only?
So this is not a one time event? You want to be able to have a flow delete all the files at once?

Nop :frowning: but i can delete one by one with the file node-red block

And I want to delete all the files in one time event

We will put together a flow and test it here…stand by.

thanks a lot
Rodrigo

Import this flow.

[{"id":"db45fd67.59a2e8","type":"exec","z":"9c7323c2.fcac3","command":"rm -r /home/dev/unsecured/*","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":480,"y":340,"wires":[["6dbbd840.55d72"],["6dbbd840.55d72"],["6dbbd840.55d72"]]},{"id":"baa0bb03.8dbaa","type":"inject","z":"9c7323c2.fcac3","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":340,"wires":[["db45fd67.59a2e8"]]},{"id":"6dbbd840.55d72","type":"debug","z":"9c7323c2.fcac3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":340,"wires":[]}]

At the moment it has a manual inject, uses the ‘Exec’ node to run a Linux command and the debug is for information.
This is what it will look like;

Note that it will delete every file from the /home/dev/unsecured directory.
The rm is remove, the -r recursive and the * is everything.
Just be a little careful with this… But it will do what you asked…

Works with a few files, but the list of files is to long.

Wow. You really do have a LOT of files…
Can you tweak the command to delete them by batches?

Your right….a lot…lot…so very lot of files.
I delete by parts…for example:

rm -r /home/dev/unsecured/201906*
rm -r /home/dev/unsecured/201807*

And Works fine!!!
Thanks a lot…lot…lot!
Rodrigo

1 Like

Having an issue deleting files with NODE-RED.
Started out using flows that worked before without success, so tried using the flow you developed.

This is command line
rm -rf /home/dev/unsecured/*

Here is the ERROR:
Command failed: rm -rf /home/dev/unsecured/*rm: cannot remove ‘/home/dev/unsecured/PARAMETER/COLORANT_I32.BIN’: Operation not permittedrm: cannot remove ‘/home/dev/unsecured/PARAMETER/COLORANT_INIT.BIN’: Operation not permittedrm: cannot remove ‘/home/dev/unsecured/PARAMETER/COLORANT_STRING.BIN’: Operation not permittedrm: cannot remove ‘/home/dev/unsecured/PARAMETER/COLORANT_F.BIN’: Operation not permitted

Tried multiple adjustments to the command line to delete individual files (wild card, individual names, etc.) without any luck.

Deleted the files under PARAMETER within Groov Manage, now when I run the command (original) we can delete the directory.
My understanding is the rm -rf is force remove directory which should delete everything.

Only have 4 small files but unable to delete using commands.
I’ve done this before with Node Red not sure what is preventing us from deleting files generated by PACControl.

Any Ideas ?

Ok. (Sorry for the slow reply, lots going on - You will read about it on Monday!)

Yes, it makes sense what you are seeing.
The files have been created by PAC Control, so they are owned by user ‘pac22’.
Node-RED is run by user ‘dev’.
User dev is not allowed to remove (even with the -rf switch) files owned by pac22. Hence you get the ‘Operation not permitted’.
The Node-RED flow in this forum thread worked because the original files were created by the Node-RED user, so they can delete their own files.

Thanks Ben
Anyway around this limitation ? (ie. assign pac22 user in node red ?, etc. )
This is an offshoot of our conversation about deleting directories in PACControl.

For now, I setup PACControl to delete the files and now have a variable to trigger Node-Red to delete the directory. Not ideal (all in PACControl or all in Node-Red) but it will work.

As always thanks for your help.