Dňa 03.03.2013 23:04 Sharon Kimble wrote / napísal(a):
> I'm trying to get a bash script working from a cron job that will empty
> trash of all files and directories that are older than $N [7 days in
> this case]. This partly works but is very inefficient in that it
> doesn't delete everything that is available to be deleted, just tends
> to leave stuff with no apparent reasoning.
>
The autotrash package was mentioned. I have this script:
#!/bin/bash
# remove files older than 10 days
OLD=10
#pre každý prípojný bod, ktorý je blokové zariadenie
for MOUNTPOINT in $(mount | egrep "^/dev" | awk '{print $1 "@" $3}'); do
#DEVICE=${MOUNTPOINT/@*}
#echo "Debug: $DEVICE"
PATH=${MOUNTPOINT#*@}
TRASH=${PATH}/.Trash-${UID}
if [ -d ${TRASH} ]; then
autotrash --days $OLD --trash-path $TRASH &
fi
done
This script is regularly executed from my fcrontab, but you can call it
from the ~/.xsessionrc file. Script cheecks the mount points and the
.Trash-$UID directories, then executes the autotrash on these
directories (Trash's paths).
regards
--
Slavko
http://slavino.sk
Attachment:
signature.asc
Description: OpenPGP digital signature