script delete files with subfolder

SMB, NFS, FTP, web file manager and Rsync server.
Locked
User avatar
oscar1412
Posts: 26
Joined: 05 Sep 2022, 00:49
Spain

script delete files with subfolder

Post by oscar1412 »

Hello, can someone help me, this NAS is connected by ftp to a camera recorder, and it would need the files to be deleted automatically through a script. :(
User avatar
Gremlin
Gold Member
Posts: 1631
Joined: 02 Dec 2022, 22:31
Great Britain

Re: script delete files with subfolder

Post by Gremlin »

I do this in Scheduled Tasks:

Code: Select all

find /Volume2/IPCAM/ -name P*.jpg -mtime +6 -print -delete
find /Volume2/IPCAM/ -name A*.jpg -mtime +120 -print -delete
find /Volume2/IPCAM/ -type d -empty -print -delete
find /Volume2/DVR/ -name *.storage -mtime +120 -print -delete
find /Volume2/DVR/ -type d -empty -print -delete
Find and delete different types of files (P* are regular pictures; A* are alarm generated in my system) and dvr recordings all at varying age (6 days; 120 days. Prints an output of all files deleted which is both logged and emailed to my admin account.
F5-221 TOS7.0.0777 - 4x4TB (Ironwolf) Traid
F2-424 TOS7.0.0777 - 2x500GB nvme (P3) Traid, 2x6TB HDD (HGST) Traid
F2-221 TOS7.0.0777 - 1x3TB Ext4, 1x4TB Btrfs
F2-425+ TOS7.0.0777 - 2x500GB nvme (P3) Traid, 2x6TB HDD (EXOS) Traid
User avatar
oscar1412
Posts: 26
Joined: 05 Sep 2022, 00:49
Spain

Re: script delete files with subfolder

Post by oscar1412 »

In tos 4.2 and e tos 5 can I do this script? In tos 4.2 it is understood that it is done through ssh?
User avatar
Gremlin
Gold Member
Posts: 1631
Joined: 02 Dec 2022, 22:31
Great Britain

Re: script delete files with subfolder

Post by Gremlin »

I have never used TOS4, so I can't comment. If you have a method to run cron, you can run individual commands or a script. Of course, you cannot run the exact commands in the example You would have to modify them to suit your environment. And, naturally, it would help if you told people what your environment is. There are no clues in your original post and I gave up crystal gazing years ago. :P
F5-221 TOS7.0.0777 - 4x4TB (Ironwolf) Traid
F2-424 TOS7.0.0777 - 2x500GB nvme (P3) Traid, 2x6TB HDD (HGST) Traid
F2-221 TOS7.0.0777 - 1x3TB Ext4, 1x4TB Btrfs
F2-425+ TOS7.0.0777 - 2x500GB nvme (P3) Traid, 2x6TB HDD (EXOS) Traid
User avatar
aschang
Posts: 8
Joined: 28 Nov 2023, 19:00

Re: script delete files with subfolder

Post by aschang »

Hello How did you mount your FTP to acceede to Camera SD card ?
User avatar
Gremlin
Gold Member
Posts: 1631
Joined: 02 Dec 2022, 22:31
Great Britain

Re: script delete files with subfolder

Post by Gremlin »

Not sure I follow. FTP is FTP ;) FTP server opens a port(s) and you allocate appropriate space and permissions for that space. Your camera then communicates with the server port using ftp client built into the camera(s). My (cheap, chinese) cameras operate without an sd card but that limits me to only sending pictures to the server (NAS in this case). Video output requires the sd card to record video and then that can be sent to ftp server. (But I don't need the video output to the NAS as I already have Hybrid DVR recording everything.) I have been testing Surveillance Manager, but it is lacking some functions for me.
F5-221 TOS7.0.0777 - 4x4TB (Ironwolf) Traid
F2-424 TOS7.0.0777 - 2x500GB nvme (P3) Traid, 2x6TB HDD (HGST) Traid
F2-221 TOS7.0.0777 - 1x3TB Ext4, 1x4TB Btrfs
F2-425+ TOS7.0.0777 - 2x500GB nvme (P3) Traid, 2x6TB HDD (EXOS) Traid
Locked

Return to “File Services”