NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
EtherZhang
Mar 17, 2017Aspirant
Auto clean "Recycle bin" on OS6.6 ?
I have looked though this post: https://community.netgear.com/t5/Using-your-ReadyNAS/Can-Recycle-Bin-be-enabled-for-CIFS-and-OS-6-1-2-on-a-314/td-p/856707 And I have successfully enabled the ...
- Apr 05, 2017
So the conclusion of the solution is here:
1. Create file:
/etc/frontview/samba/addons/addons.conf
2. Edit addons.conf according to your existing shares, if you want hide the recycle bin folder, add "." as I did:
[share1] vfs objects = recycle recycle:repository = .Recycle Bin recycle:keeptree = yes recycle:versions = no [share2] vfs objects = recycle recycle:repository = .Recycle Bin recycle:keeptree = yes recycle:versions = no
3. Reload the config file by go to the frontview web interface -> Shares and edit one of your current shares and change something then press OK. The recycle bin will now working on your NAS. Next are how to enable autoclean function for the recycle bin.
4. Create file
/frontview/bin/clean_recycle_bins
and edit it as below:
#!/usr/bin/perl #------------------------------------------------------------------------- # Copyright 2007, NETGEAR # All rights reserved. #------------------------------------------------------------------------- # # exit if( -f "/ramfs/.clean_recycle_bins.lock" ); # open(LOCK, ">/ramfs/.clean_recycle_bins.lock"); # close(LOCK); # while ( -f "/ramfs/spindown" ) { # local $/; # open(SPIN, "/ramfs/spindown"); # if( <SPIN> =~ ":1" ) { # sleep(530); # } # else { # last; # } # } use lib qw( /frontview/lib ); # use Frontview; # # my $fv = new Frontview; # $fv->Account_get_info(); # $fv->Service_get_info(); open(IN, "/etc/frontview/recycle.conf") || exit; my @dirlist = <IN>; close(IN); # if( $fv->{Service}{USER_HOME_DIRECTORY} && # $fv->{Service}{USER_HOME_DIRECTORY_RECYCLE} ) # { # my $path; # my $recycle_max_days = $fv->{Service}{USER_HOME_DIRECTORY_RECYCLE_MAX_DAYS}; # $recycle_max_days = $HOME_RECYCLE_AGE_LIMIT if( !$recycle_max_days ); # my $recycle_max_size = $fv->{Service}{USER_HOME_DIRECTORY_RECYCLE_MAX_SIZE}; # $recycle_max_size = $HOME_RECYCLE_MB_LIMIT if( !$recycle_max_size ); # # foreach my $user( sort keys %{ $fv->{Account}{user} } ) # { # if( -d "$fv->{Account}{user}{$user}{home}/.Recycle Bin" ) # { # $path = $fv->{Account}{user}{$user}{home}; # push @dirlist, "$user!!$path!!$recycle_max_size!!$recycle_max_days"; # } # } # } foreach (@dirlist) { chomp; my ($share, $path, $mb_limit, $age_limit) = split('!!'); if( $age_limit ) { system("find '$path/.Recycle Bin' -type f -ctime +$age_limit -exec rm -rf {} \\; &>/dev/null"); } if( $mb_limit ) { my $dev = `df $path | tail -1 | awk '{print \$1}'`; chomp $dev; my $blocksize = `dumpe2fs -h $dev 2>/dev/null | grep 'Block size' | awk '{print \$3}'`; chomp $blocksize; my $recycle_mb = `du -sm '$path/.Recycle Bin' 2>/dev/null`; chomp $recycle_mb; if( $recycle_mb > $mb_limit ) { my %files; open(FIND, "find '$path/.Recycle Bin' -type f -printf '%p!=!=%C@!=!=%s\n' |"); while(<FIND>) { chomp; my ($name, $time, $size) = split('!=!='); while( exists $files{$time} ) { ++$time; } $files{$time}{name} = $name; $files{$time}{size} = $size > $blocksize ? $size : $blocksize; } close(FIND); my $total_size = 0; my $byte_limit = ($mb_limit * 1024 * 1024); foreach my $time (reverse sort keys %files) { $total_size = ($total_size + $files{$time}{size}); if( $total_size > $byte_limit ) { unlink("$files{$time}{name}"); } } } } # Do a reverse sort so we can rmdir child directories before the parents. open(FIND, "find '$path/.Recycle Bin' -type d 2>/dev/null | sort -r |"); while(<FIND>) { chomp; rmdir; } close(FIND); } close(IN); # unlink("/ramfs/.clean_recycle_bins.lock");
PS: You can modify all the '$path/.Recycle Bin' by using your own recycle bin name you used in file addons.conf at the beginning.
5. Create file:
/etc/frontview/recycle.conf
then edit it like this:
share1!!/data/share1!!0!!1 share2!!/data/share2!!0!!1
The last digit "1" I use here represent the how old of the files inside the recycle bin you want to delete when this scrip runs, 1 means older than 1 day, you can set it to 30 then it will only clean files that stays in the recycle bin folder more than one month.
6. Create a Cron by adding a file called "autoclean" or whatever into "/etc/cron.d" folder, then edit the file as below:
0 1 * * * root /frontview/bin/clean_recycle_bins start
Then run
/etc/init.d/cron force-reload
and
/etc/init.d/cron restart
This will allow the scrip to run at every day's 01:00 am and clean the recycle bin according to the "recycle.conf". You can modified it if you know how to write a cron script.
7. Remember all the files that you created here should have 0755 permissions, check this first if you received a error on anything.
FramerV
Apr 04, 2017NETGEAR Employee Retired
Hi EtherZhang,
We are monitoring this thread and we would like to know of the current status on your end. Please post/update us so that we can check if there is anything that we can do for you.
Regards,
EtherZhang
Apr 05, 2017Aspirant
So the conclusion of the solution is here:
1. Create file:
/etc/frontview/samba/addons/addons.conf
2. Edit addons.conf according to your existing shares, if you want hide the recycle bin folder, add "." as I did:
[share1] vfs objects = recycle recycle:repository = .Recycle Bin recycle:keeptree = yes recycle:versions = no [share2] vfs objects = recycle recycle:repository = .Recycle Bin recycle:keeptree = yes recycle:versions = no
3. Reload the config file by go to the frontview web interface -> Shares and edit one of your current shares and change something then press OK. The recycle bin will now working on your NAS. Next are how to enable autoclean function for the recycle bin.
4. Create file
/frontview/bin/clean_recycle_bins
and edit it as below:
#!/usr/bin/perl #------------------------------------------------------------------------- # Copyright 2007, NETGEAR # All rights reserved. #------------------------------------------------------------------------- # # exit if( -f "/ramfs/.clean_recycle_bins.lock" ); # open(LOCK, ">/ramfs/.clean_recycle_bins.lock"); # close(LOCK); # while ( -f "/ramfs/spindown" ) { # local $/; # open(SPIN, "/ramfs/spindown"); # if( <SPIN> =~ ":1" ) { # sleep(530); # } # else { # last; # } # } use lib qw( /frontview/lib ); # use Frontview; # # my $fv = new Frontview; # $fv->Account_get_info(); # $fv->Service_get_info(); open(IN, "/etc/frontview/recycle.conf") || exit; my @dirlist = <IN>; close(IN); # if( $fv->{Service}{USER_HOME_DIRECTORY} && # $fv->{Service}{USER_HOME_DIRECTORY_RECYCLE} ) # { # my $path; # my $recycle_max_days = $fv->{Service}{USER_HOME_DIRECTORY_RECYCLE_MAX_DAYS}; # $recycle_max_days = $HOME_RECYCLE_AGE_LIMIT if( !$recycle_max_days ); # my $recycle_max_size = $fv->{Service}{USER_HOME_DIRECTORY_RECYCLE_MAX_SIZE}; # $recycle_max_size = $HOME_RECYCLE_MB_LIMIT if( !$recycle_max_size ); # # foreach my $user( sort keys %{ $fv->{Account}{user} } ) # { # if( -d "$fv->{Account}{user}{$user}{home}/.Recycle Bin" ) # { # $path = $fv->{Account}{user}{$user}{home}; # push @dirlist, "$user!!$path!!$recycle_max_size!!$recycle_max_days"; # } # } # } foreach (@dirlist) { chomp; my ($share, $path, $mb_limit, $age_limit) = split('!!'); if( $age_limit ) { system("find '$path/.Recycle Bin' -type f -ctime +$age_limit -exec rm -rf {} \\; &>/dev/null"); } if( $mb_limit ) { my $dev = `df $path | tail -1 | awk '{print \$1}'`; chomp $dev; my $blocksize = `dumpe2fs -h $dev 2>/dev/null | grep 'Block size' | awk '{print \$3}'`; chomp $blocksize; my $recycle_mb = `du -sm '$path/.Recycle Bin' 2>/dev/null`; chomp $recycle_mb; if( $recycle_mb > $mb_limit ) { my %files; open(FIND, "find '$path/.Recycle Bin' -type f -printf '%p!=!=%C@!=!=%s\n' |"); while(<FIND>) { chomp; my ($name, $time, $size) = split('!=!='); while( exists $files{$time} ) { ++$time; } $files{$time}{name} = $name; $files{$time}{size} = $size > $blocksize ? $size : $blocksize; } close(FIND); my $total_size = 0; my $byte_limit = ($mb_limit * 1024 * 1024); foreach my $time (reverse sort keys %files) { $total_size = ($total_size + $files{$time}{size}); if( $total_size > $byte_limit ) { unlink("$files{$time}{name}"); } } } } # Do a reverse sort so we can rmdir child directories before the parents. open(FIND, "find '$path/.Recycle Bin' -type d 2>/dev/null | sort -r |"); while(<FIND>) { chomp; rmdir; } close(FIND); } close(IN); # unlink("/ramfs/.clean_recycle_bins.lock");
PS: You can modify all the '$path/.Recycle Bin' by using your own recycle bin name you used in file addons.conf at the beginning.
5. Create file:
/etc/frontview/recycle.conf
then edit it like this:
share1!!/data/share1!!0!!1 share2!!/data/share2!!0!!1
The last digit "1" I use here represent the how old of the files inside the recycle bin you want to delete when this scrip runs, 1 means older than 1 day, you can set it to 30 then it will only clean files that stays in the recycle bin folder more than one month.
6. Create a Cron by adding a file called "autoclean" or whatever into "/etc/cron.d" folder, then edit the file as below:
0 1 * * * root /frontview/bin/clean_recycle_bins start
Then run
/etc/init.d/cron force-reload
and
/etc/init.d/cron restart
This will allow the scrip to run at every day's 01:00 am and clean the recycle bin according to the "recycle.conf". You can modified it if you know how to write a cron script.
7. Remember all the files that you created here should have 0755 permissions, check this first if you received a error on anything.
- SandsharkApr 06, 2017Sensei - Experienced User
Actually, I believe that's the way it works on OS4.x, too. An empty recycle bin is deleted.
Thanks for running with the baton. I think I'll be doing this myself, very soon.
Related Content
NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology!
Join Us!