Want to schedule delete files and folders on attached USB drive.

Introduce yourself to us and other members here, or share your own product reviews, suggestions, and tips and tricks of using QNAP products.
Locked
User avatar
sharper9
Know my way around
Posts: 196
Joined: Fri Jun 06, 2008 6:10 pm

Re: Want to schedule delete files and folders on attached USB drive.

Post by sharper9 »

OneCD wrote:Or, you could extend Surveillance Station's overwrite days to something high (like 30 days). ;)
Currently I'm thinking the same - but Iv only got a 1TB space left in total on QNAP with the 11day setting thus my 'attempt' at utilizing the MSD for a short achive.
All the best

TS251A 8GB 2 x 3TB JBOD for LMS and loads of other stuff. 2 Hikvision DS-2CD2342WD-I
Firmware 4.4.3.1354 - Windows 11 + 2 x iPads
User avatar
OneCD
Guru
Posts: 12146
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Want to schedule delete files and folders on attached USB drive.

Post by OneCD »

That's OK, you wouldn't be storing 30 days of videos on the NAS. If you use archive-old-stuff.sh once per day, then the excess get shifted out to your USB drive.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
sharper9
Know my way around
Posts: 196
Joined: Fri Jun 06, 2008 6:10 pm

Re: Want to schedule delete files and folders on attached USB drive.

Post by sharper9 »

OneCD wrote:That's OK, you wouldn't be storing 30 days of videos on the NAS. If you use archive-old-stuff.sh once per day, then the excess get shifted out to your USB drive.
OK

So I need to make sure archive-old-stuff.sh is running once a day, with current configuration?

Anything else?
All the best

TS251A 8GB 2 x 3TB JBOD for LMS and loads of other stuff. 2 Hikvision DS-2CD2342WD-I
Firmware 4.4.3.1354 - Windows 11 + 2 x iPads
User avatar
OneCD
Guru
Posts: 12146
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Want to schedule delete files and folders on attached USB drive.

Post by OneCD »

sharper9 wrote:So I need to make sure archive-old-stuff.sh is running once a day, with current configuration?
Yes, but you'll need to uncomment the crontab line for archive-old-stuff.sh again, by removing the leading hash character.
sharper9 wrote:Anything else?
Not that I'm aware of. I guess we'll find out. :DD

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
sharper9
Know my way around
Posts: 196
Joined: Fri Jun 06, 2008 6:10 pm

Re: Want to schedule delete files and folders on attached USB drive.

Post by sharper9 »

Code: Select all

[~] # crontab -l
# m h dom m dow cmd
0 3 * * 0 /etc/init.d/idmap.sh dump
0 4 * * * /sbin/hwclock -s
0 3 * * * /sbin/vs_refresh
0 3 * * * /sbin/clean_reset_pwd
0-59/15 * * * * /etc/init.d/nss2_dusg.sh
30 7 * * * /sbin/clean_upload_file
0 2 * * * /sbin/qfstrim
0-59/10 * * * * /etc/init.d/storage_usage.sh
30 3 * * * /sbin/notice_log_tool -v -R
10 15 * * * /usr/bin/power_clean -c 2>/dev/null
10 0 * * * /etc/init.d/antivirus.sh scan 1
0 0 * * * /etc/init.d/antivirus.sh archive_log
08 0 */1 * * /etc/init.d/antivirus.sh update_db
* * * * * /mnt/ext/opt/netmgr/util/lock_timer.sh
35 7 * * * /sbin/qbox_util -c  > /dev/null 2>/dev/null
19 * * * * /sbin/qddns_check 2>/dev/null
0 5 * * * /share/50014EE20BA4E444_DATA/.system/archive-old-stuff.sh >>
/share/50014EE20BA4E444_DATA/.system/nvr-archiver.log


*/3 * * * * /etc/config/qsync_init.sh
4 3 * * 3 /etc/init.d/backup_conf.sh
All done (I hope)
Thanks once again
All the best

TS251A 8GB 2 x 3TB JBOD for LMS and loads of other stuff. 2 Hikvision DS-2CD2342WD-I
Firmware 4.4.3.1354 - Windows 11 + 2 x iPads
User avatar
sharper9
Know my way around
Posts: 196
Joined: Fri Jun 06, 2008 6:10 pm

Re: Want to schedule delete files and folders on attached USB drive.

Post by sharper9 »

Sadly there has been no transfer to or deletion on MSD.

Are we at end with this as I can quite understand this has go on for good while.
All the best

TS251A 8GB 2 x 3TB JBOD for LMS and loads of other stuff. 2 Hikvision DS-2CD2342WD-I
Firmware 4.4.3.1354 - Windows 11 + 2 x iPads
User avatar
OneCD
Guru
Posts: 12146
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Want to schedule delete files and folders on attached USB drive.

Post by OneCD »

sharper9 wrote:Sadly there has been no transfer to or deletion on MSD.
Can you please post the contents of your log file?

Code: Select all

cat /share/50014EE20BA4E444_DATA/.system/nvr-archiver.log
sharper9 wrote:Are we at end with this as I can quite understand this has go on for good while.
That's up to you. This can all work, as long as everything is correctly configured. However, I understand if you are frustrated. ;)

One thing I'm not sure of though is that in your previous posting of crontab, it displays with a line-break just where the displayed output is redirected to the log:

Code: Select all

0 5 * * * /share/50014EE20BA4E444_DATA/.system/archive-old-stuff.sh >>
/share/50014EE20BA4E444_DATA/.system/nvr-archiver.log
That line-break should not be there.

This may have just been a copy-paste bug. Can you please confirm that the crontab line actually looks like this in your editor?

Code: Select all

0 5 * * * /share/50014EE20BA4E444_DATA/.system/archive-old-stuff.sh >> /share/50014EE20BA4E444_DATA/.system/nvr-archiver.log
Another thing to check for is that the directories in your source path should be building up. There need to be over 15 before any are moved to USB. How many are there now?

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
sharper9
Know my way around
Posts: 196
Joined: Fri Jun 06, 2008 6:10 pm

Re: Want to schedule delete files and folders on attached USB drive.

Post by sharper9 »

I would like to get it working.
Im just very aware of he great effort you are putting in.

This is the structure on MSD where the video files on reside
I:\channel1\2017-03-13\01.avi
I included this as I wondered if might be stopping the deletion of the directory on MSD?



Code: Select all

[~] # cat /share/50014EE20BA4E444_DATA/.system/nvr-archiver.log

runtime: [Tue Apr 11 05:00:02 BST 2017]
- moving excess directories from [/share/Recordings/record_nvr/channel1] to [/share/MySmallDisk/channel1] ...
done.
- deleting excess directories from [/share/MySmallDisk/channel1] ...
done.

runtime: [Tue Apr 11 05:00:02 BST 2017]
- moving excess directories from [/share/Recordings/record_nvr/channel2] to [/share/MySmallDisk/channel2] ...
done.
- deleting excess directories from [/share/MySmallDisk/channel2] ...
done.

runtime: [Wed Apr 12 05:00:02 BST 2017]
- moving excess directories from [/share/Recordings/record_nvr/channel1] to [/share/MySmallDisk/channel1] ...
done.
- deleting excess directories from [/share/MySmallDisk/channel1] ...
done.

runtime: [Wed Apr 12 05:00:02 BST 2017]
- moving excess directories from [/share/Recordings/record_nvr/channel2] to [/share/MySmallDisk/channel2] ...
done.
- deleting excess directories from [/share/MySmallDisk/channel2] ...
done.

runtime: [Thu Apr 13 05:00:02 BST 2017]
- moving excess directories from [/share/Recordings/record_nvr/channel1] to [/share/MySmallDisk/channel1] ...
done.
- deleting excess directories from [/share/MySmallDisk/channel1] ...
done.

runtime: [Thu Apr 13 05:00:02 BST 2017]
- moving excess directories from [/share/Recordings/record_nvr/channel2] to [/share/MySmallDisk/channel2] ...
done.
- deleting excess directories from [/share/MySmallDisk/channel2] ...
done.

runtime: [Fri Apr 14 05:00:02 BST 2017]
- moving excess directories from [/share/Recordings/record_nvr/channel1] to [/share/MySmallDisk/channel1] ...
done.
- deleting excess directories from [/share/MySmallDisk/channel1] ...
done.

runtime: [Fri Apr 14 05:00:02 BST 2017]
- moving excess directories from [/share/Recordings/record_nvr/channel2] to [/share/MySmallDisk/channel2] ...
done.
- deleting excess directories from [/share/MySmallDisk/channel2] ...
done.

runtime: [Sat Apr 15 05:00:02 BST 2017]
- moving excess directories from [/share/Recordings/record_nvr/channel1] to [/share/MySmallDisk/channel1] ...
done.
- deleting excess directories from [/share/MySmallDisk/channel1] ...
done.

runtime: [Sat Apr 15 05:00:02 BST 2017]
- moving excess directories from [/share/Recordings/record_nvr/channel2] to [/share/MySmallDisk/channel2] ...
done.
- deleting excess directories from [/share/MySmallDisk/channel2] ...
done.
All the best

TS251A 8GB 2 x 3TB JBOD for LMS and loads of other stuff. 2 Hikvision DS-2CD2342WD-I
Firmware 4.4.3.1354 - Windows 11 + 2 x iPads
User avatar
OneCD
Guru
Posts: 12146
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Want to schedule delete files and folders on attached USB drive.

Post by OneCD »

sharper9 wrote:I would like to get it working.
Im just very aware of he great effort you are putting in.
That's OK, no problem. :DD
sharper9 wrote:This is the structure on MSD where the video files on reside
I:\channel1\2017-03-13\01.avi
I included this as I wondered if might be stopping the deletion of the directory on MSD?
That is how the directory structure appears on a Windows PC. On your NAS, it's slightly different.
sharper9 wrote:

Code: Select all

runtime: [Sat Apr 15 05:00:02 BST 2017]
- moving excess directories from [/share/Recordings/record_nvr/channel2] to [/share/MySmallDisk/channel2] ...
done.
- deleting excess directories from [/share/MySmallDisk/channel2] ...
done.
Ah, this does indicate a problem. There are no log entries after 5am on Saturday. This seems to indicate that the archive script is not running. We did disable it around that time. A couple of days later, we should have switched it back on again.

So, there are a couple of things to check:
  1. Please list the directories on your NAS:

    Code: Select all

    ls -dr1 /share/Recordings/record_nvr/channel1/*
  2. Please check your crontab file as per my previous post. Ensure it is loaded into memory afterwards with:

    Code: Select all

    crontab /etc/config/crontab && /etc/init.d/crond.sh restart
  3. Run this to check the list:

    Code: Select all

    crontab -l
    and please post it back here.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
sharper9
Know my way around
Posts: 196
Joined: Fri Jun 06, 2008 6:10 pm

Re: Want to schedule delete files and folders on attached USB drive.

Post by sharper9 »

I'll do this in 'my' morning!
Thx
All the best

TS251A 8GB 2 x 3TB JBOD for LMS and loads of other stuff. 2 Hikvision DS-2CD2342WD-I
Firmware 4.4.3.1354 - Windows 11 + 2 x iPads
User avatar
sharper9
Know my way around
Posts: 196
Joined: Fri Jun 06, 2008 6:10 pm

Re: Want to schedule delete files and folders on attached USB drive.

Post by sharper9 »

Code: Select all

[~] # ls -dr1 /share/Recordings/record_nvr/channel1/*
/share/Recordings/record_nvr/channel1/2017-04-20/
/share/Recordings/record_nvr/channel1/2017-04-19/
/share/Recordings/record_nvr/channel1/2017-04-18/
/share/Recordings/record_nvr/channel1/2017-04-17/
/share/Recordings/record_nvr/channel1/2017-04-16/
/share/Recordings/record_nvr/channel1/2017-04-15/
/share/Recordings/record_nvr/channel1/2017-04-14/
/share/Recordings/record_nvr/channel1/2017-04-13/
/share/Recordings/record_nvr/channel1/2017-04-12/
/share/Recordings/record_nvr/channel1/2017-04-11/
/share/Recordings/record_nvr/channel1/2017-04-10/
There are only 11 although I set three days ago to 20!
This due to the stupid surveillance station software. It has two settings area to set the length to retain, one in the individual camera and another in the admin settings :evil:

Anyway both set NOW to 20 days BEFORE it overwrites the oldest!

Code: Select all

[~] # crontab -l
# m h dom m dow cmd
0 3 * * 0 /etc/init.d/idmap.sh dump
0 4 * * * /sbin/hwclock -s
0 3 * * * /sbin/vs_refresh
0 3 * * * /sbin/clean_reset_pwd
0-59/15 * * * * /etc/init.d/nss2_dusg.sh
30 7 * * * /sbin/clean_upload_file
0 2 * * * /sbin/qfstrim
0-59/10 * * * * /etc/init.d/storage_usage.sh
30 3 * * * /sbin/notice_log_tool -v -R
10 15 * * * /usr/bin/power_clean -c 2>/dev/null
10 0 * * * /etc/init.d/antivirus.sh scan 1
0 0 * * * /etc/init.d/antivirus.sh archive_log
08 0 */1 * * /etc/init.d/antivirus.sh update_db
* * * * * /mnt/ext/opt/netmgr/util/lock_timer.sh
35 7 * * * /sbin/qbox_util -c  > /dev/null 2>/dev/null
19 * * * * /sbin/qddns_check 2>/dev/null
0 5 * * * /share/50014EE20BA4E444_DATA/.system/archive-old-stuff.sh >> /share/50014EE20BA4E444_DATA/.system/nvr-archiver.log


*/3 * * * * /etc/config/qsync_init.sh
4 3 * * 3 /etc/init.d/backup_conf.sh
All the best

TS251A 8GB 2 x 3TB JBOD for LMS and loads of other stuff. 2 Hikvision DS-2CD2342WD-I
Firmware 4.4.3.1354 - Windows 11 + 2 x iPads
User avatar
OneCD
Guru
Posts: 12146
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Want to schedule delete files and folders on attached USB drive.

Post by OneCD »

sharper9 wrote:Anyway both set NOW to 20 days BEFORE it overwrites the oldest!
Okiedoke, crontab looks good and you found why the directory list was being trimmed, so now we play the waiting game... ;)

Check your USB drive again in a few days.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
sharper9
Know my way around
Posts: 196
Joined: Fri Jun 06, 2008 6:10 pm

Re: Want to schedule delete files and folders on attached USB drive.

Post by sharper9 »

Update.

Things were starting to work re your script.
But as you know I was trying to the files on the nas to 20 day!!!
I tried to use the Surveillance Station UI to set the amount of days to keep but only managed to delete all but 4 FOUR of my current recording on the NAS!!!! :twisted:
As of today I have five current recordings. But I'm going to have to wait for them to build up before your script will kick in.

Thats where we are at
All the best

TS251A 8GB 2 x 3TB JBOD for LMS and loads of other stuff. 2 Hikvision DS-2CD2342WD-I
Firmware 4.4.3.1354 - Windows 11 + 2 x iPads
User avatar
OneCD
Guru
Posts: 12146
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Want to schedule delete files and folders on attached USB drive.

Post by OneCD »

No worries, let's see how it looks a couple of weeks from now. ;)

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
sharper9
Know my way around
Posts: 196
Joined: Fri Jun 06, 2008 6:10 pm

Re: Want to schedule delete files and folders on attached USB drive.

Post by sharper9 »

Hi

I'm trying to turn off the crontab off with # to let the recording stack up on the nas HD. ATM moment the your crontab is moving them so I cant get above 13.

I put a # to stop it, but it looks wrong

Code: Select all

10 15 * * * /usr/bin/power_clean -c 2>/dev/null
19 * * * * /sbin/qddns_check 2>/dev/null
#0 5 * * * /share/50014EE20BA4E444_DATA/.system/archive-old-stuff.sh >>
/share/50014EE20BA4E444_DATA/.system/nvr-archiver.log


34 13 * * * /share/50014EE20BA4E444_DATA/.qpkg/QcloudSSLCertificate/bin/ssl_age$
4 3 * * 3 /etc/init.d/backup_conf.sh
10 0 * * * /etc/init.d/antivirus.sh scan 1
0 0 * * * /etc/init.d/antivirus.sh archive_log
42 0 */1 * * /etc/init.d/antivirus.sh update_db
* * * * * /mnt/ext/opt/netmgr/util/lock_timer.sh
35 7 * * * /sbin/qbox_util -c  > /dev/null 2>/dev/null
38 13 * * * /share/50014EE20BA4E444_DATA/.qpkg/QcloudSSLCertificate/bin/ssl_age$
0 0 * * * /usr/local/medialibrary/bin/mymediadbcmd buildall 1>/dev/null 2>/dev/$


I changed the amount of files to achieve to 21!!. I thought on the crontab.........(but can't see it now) as I could not get the NAS past the 11 day.
I think im getting confused ( :ashamed: to put it mildly)
All the best

TS251A 8GB 2 x 3TB JBOD for LMS and loads of other stuff. 2 Hikvision DS-2CD2342WD-I
Firmware 4.4.3.1354 - Windows 11 + 2 x iPads
Locked

Return to “Users' Corner”