Koozali.org: home of the SME Server

recycle bin querry

Offline kryptos

  • *****
  • 245
  • +0/-0
recycle bin querry
« on: October 21, 2008, 09:38:10 AM »
Hi all,

I want to enable recycle bin on each ibay. My question is do I have to delete the contents manually in the recycle bin so that i won't accumulate in that folder or is it automatic delete monthly or weeky?


Regards,
Rocel

Offline David Harper

  • *
  • 653
  • +0/-0
  • Watch this space
    • Workgroup Technology Solutions
Re: recycle bin querry
« Reply #1 on: October 21, 2008, 11:20:56 AM »
You could use cron (the Linux scheduler) to run a command that would clear out the Recycle Bins.

First, let's test out the command and make sure it works.

Create a shell script using pico - e.g. pico ~/clearbins.sh

Code: [Select]
#!/bin/sh
# Simple command to clear out recycle bin
# Be careful with this as it may require adapting
# Make sure to BACK UP your Ibays before testing

rm -rf /home/e-smith/files/ibays/{ibay1,ibay2,ibay3}/files/Recycle\ Bin/*


Exit pico with CTRL-X - make sure to save the script!

Now make the script executable and then test it:

Code: [Select]
chmod +x ~/clearbins.sh
~/clearbins.sh

Did everything work out? Then you can schedule the working command using a custom template. If not, go back into pico ("pico ~/clearbins.sh") and fiddle with the command as need be.

Once it's working as expected, we can create the cron template:

Code: [Select]
mkdir -p /etc/e-smith/templates-custom/etc/crontab/
pico /etc/e-smith/templates-custom/etc/crontab/90clearbins

Set the code fragment to run the job every Friday at 5pm (or whatever):

Code: [Select]
# empty the recycle bins
# runs every Friday at 5pm

0 17 * * 5 rm -rf /home/e-smith/files/ibays/{ibay1,ibay2,ibay3}/files/Recycle\ Bin/*

Save and exit pico. And finally expand the cron template:

Code: [Select]
expand-template /etc/crontab

If this works, we should probably add it to the wiki page (http://wiki.contribs.org/RecycleBin)

Offline kryptos

  • *****
  • 245
  • +0/-0
Re: recycle bin querry
« Reply #2 on: October 22, 2008, 07:18:16 AM »
hi,

Ill try this one seems to work for me. But in this link http://forums.contribs.org/index.php?topic=26185.0 its from an old post i don' know if this one exist on current sme version. Thanks anyway

Regards,
Rocel

Offline Marco Hess

  • *
  • 149
  • +0/-0
    • http://www.through-ip.com
Re: recycle bin querry
« Reply #3 on: October 23, 2008, 02:44:16 PM »
But in this link http://forums.contribs.org/index.php?topic=26185.0 its from an old post

I have a slightly updated version of that script. It scans both users and ibay Recycle Bins and only deletes those files that have been in the recycle bin for over 30 days (using the last accessed time stamp, so even old files still hang around in the bin for at least 30 days). The script can run daily or weekly from cron.

Here is the script:

Code: [Select]
#!/bin/bash

echo "+------------------------------------------------------------------------------+"
echo "|                           Samba recycle-bin cleaner                          |"
echo "+------------------------------------------------------------------------------+"

URF=$(find /home/e-smith/files/users/*/home/Recycle\ Bin/* -type f -atime +30)
if [ "$URF" !=  "" ]
then
    printf "| %-76s |\n" "The following user recycle bin files were deleted:"
    IFS=$'\n'
    for file in $URF
    do
        printf "| - %-74s |\n" "$file"
        rm -f "$file"
    done
else
    printf "| %-76s |\n" "There were no old user recycle bin files to delete."
fi

echo "+------------------------------------------------------------------------------+"

IRF=$(find /home/e-smith/files/ibays/*/files/Recycle\ Bin/* -type f -atime +30)
if [ "$IRF" !=  "" ]
then
    printf "| %-76s |\n" "The following ibays recycle bin files were deleted:"
    IFS=$'\n'
    for file in $IRF
    do
        printf "| - %-74s |\n" "$file"
        rm -f "$file"
    done
else
    printf "| %-76s |\n" "There were no old ibays recycle bin files to delete."
fi

echo "+------------------------------------------------------------------------------+"

URD=$(find /home/e-smith/files/users/*/home/Recycle\ Bin/* -type d -empty)
if [ "$URD" != "" ]
then
    printf "| %-76s |\n" "The following users recycle bin directories were deleted:"
    IFS=$'\n'
    for folder in $URD
    do
        printf "| - %-74s |\n" "$folder"
        rm -rf "$folder"
    done
else
    printf "| %-76s |\n" "There were no old user recycle bin directories to delete."
fi

echo "+------------------------------------------------------------------------------+"

IRD=$(find /home/e-smith/files/ibays/*/files/Recycle\ Bin/* -type d -empty)
if [ "$IRD" != "" ]
then
    printf "| %-76s |\n" "The following ibays recycle bin directories were deleted:"
    IFS=$'\n'
    for folder in $IRD
    do
        printf "| - %-74s |\n" "$folder"
        rm -rf "$folder"
    done
else
    printf "| %-76s |\n" "There were no old ibays recycle bin directories to delete."
fi

echo "+------------------------------------------------------------------------------+"
Adelaide - Australia

Offline David Harper

  • *
  • 653
  • +0/-0
  • Watch this space
    • Workgroup Technology Solutions
Re: recycle bin querry
« Reply #4 on: October 23, 2008, 09:16:17 PM »
Now that is just cool  8)

Offline luca219

  • ****
  • 80
  • +0/-0
Re: recycle bin querry
« Reply #5 on: December 10, 2008, 05:00:38 PM »
use the latest script indicate, but get this error
you have suggestions?

: command not found.sh: line 2:
+------------------------------------------------------------------------------+
|                           Samba recycle-bin cleaner                          |
+------------------------------------------------------------------------------+
: command not found.sh: line 6:
'ulizia-Recycle-Bin.sh: line 13: syntax error near unexpected token `do
'ulizia-Recycle-Bin.sh: line 13: `    do
 

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: recycle bin querry
« Reply #6 on: December 10, 2008, 05:38:48 PM »
use the latest script indicate, but get this error
you have suggestions?

please post your script into a "code" block,
thank you

Ciao
Stefano

Offline luca219

  • ****
  • 80
  • +0/-0
Re: recycle bin querry
« Reply #7 on: December 10, 2008, 05:49:48 PM »
is last indicated by Marco Hess
thank you

ciao luca

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: recycle bin querry
« Reply #8 on: December 10, 2008, 06:11:45 PM »
is last indicated by Marco Hess
thank you

ciao luca

Hi Luca.. I think it's not the same..

I've just copied, pasted and executed that script without any problem..

I suggest you to re-copy, paste and retry..

Ciao
stefano