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 »

Thanks - I'll get it done over the weekend
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 »

Here you go.
I changed to the start time to 5am. Hope I did it right?

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
4 3 * * 3 /etc/init.d/backup_conf.sh
19 * * * * /sbin/qddns_check 2>/dev/null
0 5 * * * /share/50014EE20BA4E444_DATA/.system/archive-old-stuff.sh
many thanks 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
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 »

Looks good. :geek:

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:Looks good. :geek:
Great thanks!
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 »

Hi
Been away for few day (hernia operation)

Noticed 25-27th of March is missing on mysmalldisk disk.

Image Image
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 »

Hey, hope you're well. :'

I've been testing this at my end and haven't been able to replicate the issue you've seen. :(

So, I've made some changes that will display some information about the move and delete operations as they occur. We'll then capture this to a log file, which can be examined later. This should tell us if something is going wrong.

Here's a new version of the script. I've already included your paths in it, and the 'safety' is already turned off.
archive-old-stuff.gz
Please download this into your Public share, then move and rename it as follows:

Code: Select all

mv /share/Public/archive-old-stuff.gz /share/50014EE20BA4E444_DATA/.system/archive-old-stuff.sh
Mark it as executable:

Code: Select all

chmod +x /share/50014EE20BA4E444_DATA/.system/archive-old-stuff.sh
Then, we need to add something to the end of your existing crontab entry.

Follow the previous process for editing your crontab file and change the entry from:

Code: Select all

0 11 * * * /share/50014EE20BA4E444_DATA/.system/archive-old-stuff.sh
to

Code: Select all

0 11 * * * /share/50014EE20BA4E444_DATA/.system/archive-old-stuff.sh >> /share/50014EE20BA4E444_DATA/.system/nvr-archiver.log
Save this as per the crontab editing process.

Then, let this run as usual for a few days. If it looks like it's not behaving itself, you can check the log file with:

Code: Select all

cat /share/50014EE20BA4E444_DATA/.system/nvr-archiver.log
You do not have the required permissions to view the files attached to this post.

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 »

Get to it in the 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 »

Done thx

be in touch
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 »

I dont think this is good :wink:

Code: Select all

[~] # cat /share/50014EE20BA4E444_DATA/.system/nvr-archiver.log
cat: /share/50014EE20BA4E444_DATA/.system/nvr-archiver.log: No such file or directory
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 »

Can you please run this and post back the result?

Code: Select all

crontab -l | grep old-stuff

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 | grep old-stuff
0 5 * * * /share/50014EE20BA4E444_DATA/.system/archive-old-stuff.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 »

Ah, you forgot to add that extra command to the end of the crontab line. ;)

It's shown in that post of mine further up this page - where you downloaded the latest script file.

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:Ah, you forgot to add that extra command to the end of the crontab line. ;)

It's shown in that post of mine further up this page - where you downloaded the latest script file.
I think I messed up on how to edit the crontab?
Cant remember, I looked but can you tell me so I get it right.
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 »

Here's what do do:
  1. Edit your crontab file:

    Code: Select all

    nano /etc/config/crontab
  2. edit your entry for archive-old-stuff.sh.

    So your crontab should then look like this. The order of the lines does not matter.
    # 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
    31 * * * * /sbin/qddns_check 2>/dev/null
    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
    4 3 * * 3 /etc/init.d/backup_conf.sh
    0 11 * * * /share/50014EE20BA4E444_DATA/.system/archive-old-stuff.sh >> /share/50014EE20BA4E444_DATA/.system/nvr-archiver.log
  3. Ensure the last line of the file is empty,
  4. Save and exit the nano editor,
  5. Load your crontab file:

    Code: Select all

    crontab /etc/config/crontab
  6. Restart the cron daemon:

    Code: Select all

    /etc/init.d/crond.sh restart
  7. Confirm that your new crontab file has been loaded by the cron daemon:

    Code: Select all

    crontab -l

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:Here's what do do:
  1. Edit your crontab file:

    Code: Select all

    nano /etc/config/crontab
  2. edit your entry for archive-old-stuff.sh.

    So your crontab should then look like this. The order of the lines does not matter.
    # 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
    31 * * * * /sbin/qddns_check 2>/dev/null
    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
    4 3 * * 3 /etc/init.d/backup_conf.sh
    0 11 * * * /share/50014EE20BA4E444_DATA/.system/archive-old-stuff.sh >> /share/50014EE20BA4E444_DATA/.system/nvr-archiver.log
  3. Ensure the last line of the file is empty,
  4. Save and exit the nano editor,
  5. Load your crontab file:

    Code: Select all

    crontab /etc/config/crontab
  6. Restart the cron daemon:

    Code: Select all

    /etc/init.d/crond.sh restart
  7. Confirm that your new crontab file has been loaded by the cron daemon:

    Code: Select all

    crontab -l

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

4 3 * * 3 /etc/init.d/backup_conf.sh
Hope this looks ok.
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”