Koozali.org: home of the SME Server
Obsolete Releases => SME Server 7.x => Topic started by: kryptos 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
-
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
#!/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:
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:
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):
# 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:
expand-template /etc/crontab
If this works, we should probably add it to the wiki page (http://wiki.contribs.org/RecycleBin)
-
hi,
Ill try this one seems to work for me. But in this link http://forums.contribs.org/index.php?topic=26185.0 (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
-
But in this link http://forums.contribs.org/index.php?topic=26185.0 (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:
#!/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 "+------------------------------------------------------------------------------+"
-
Now that is just cool 8)
-
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
-
use the latest script indicate, but get this error
you have suggestions?
please post your script into a "code" block,
thank you
Ciao
Stefano
-
is last indicated by Marco Hess
thank you
ciao luca
-
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