stefan
November 23, 2006, 3:14pm
1
hi i need to make a script that will check the directories of the users on mp3 or mp4 files. if so they must be automaticly deleted and they have to get a warning message instead.
this should be running every day at 1 pm and should be done within the cron file.
could someone help me with this question?
if so your blessed.
yhnx in advance
you can start using the "find" command. something like this:
find /home -name "*.mp[3-4]" -type f | xargs ls -l | awk '{ print $3 "," $9 }' > mpfiles.txt
for x in `cat mpfiles.txt`
do
user=`echo ${x} | cut -f1 -d","`
file=`echo ${x} | cut -f2 -d","`
recipient=${user}@<domain>
rm ${file}
mail -s "File ${file} was deleted on your directory." ${recipient}
done
but if you want to delete without email this is much simplier:
find /home -name "*.mp[3-4]" -type f -exec rm{}\;
where /home is the starting directory of your users.
stefan
November 24, 2006, 3:43am
3
thnx,
i already found out that i need to run the script within the cron file to let it happen every day at 13.00 o clock.
but i cant say enough to thank you