auto dump of user trash??

closer

Registered
Question #2 .... another easily done task in MacMgr but can't find out where to do this in WKGrpMgr... when a student sends a file to trash it stays there until they manually delete it... can this be set to auto delete the trash when anything is dumped in there?
 
Well, if you want, either empty the trash with a script at login, logout, or with a cron task that runs every x minutes.

Here's something to work around an AD user not being able to empty the trash. Its simple and just deletes the contents of the trash for the logged in user.

#!/bin/bash
#Empty trash in an AD Domain
#
#Written by Michael Dhaliwal

#Kiss your trash good bye!
rm -rf ~/.Trash/*
echo "Done!"
exit
 
Hi Go3

thanks for another speedy reply... but its the noknowledgeofscripting guy here... (but ready to learn)... I'm not completely terminal illiterate though... so I'm a touch above newbie in this respect!

Go3iverson said:
Well, if you want, either empty the trash with a script at login, logout, or with a cron task that runs every x minutes.

Here's something to work around an AD user not being able to empty the trash. Its simple and just deletes the contents of the trash for the logged in user.

#!/bin/bash
#Empty trash in an AD Domain
#
#Written by Michael Dhaliwal

#Kiss your trash good bye!
rm -rf ~/.Trash/*
echo "Done!"
exit

ok.. so where do I put the above script... and I like the idea of the cron that actually deletes the .Trash location... would this do this for all users on the server... sounds like a plan to me!
 
Put the script someplace where it can be called properly. I usually say Users/Shared simply because its the most straight forward place for most folks. Its not a powerful script, so if someone were to steal it, they'd just empty their own trash. :)

I do server work all day, night and weekend, so speedy replies are usually my forte. ;)
 
It is possible to delete all Users .Trash files

First you need to establish

1. Do you really need this? What if someone accidently deletes something and wants to get it back they can't get it back the next day

2. If my method works for you by test test and test before going live with this

Ok now i've got that off my chest here we go.

There are many ways of doing this from Applescripts, Applescript applications, user login hooks with workgroup manager, third pary applications like Onyx or Cocktail or via unix commands via a script

I have chosen to use unix command via a bash script via other methods
because

1.Applescripts can get over complicated, and Applescripted application rely on a user double clicking it and whats the point of that.

2.Forced workgroup manager login and other settings don't always work and are not reliable enough to get the job done

3.Applescripted applications at forced login may cause the system to freeze with the spinning beach ball of Death (SPOD)

4.Third party applications can be risky because you don't know what they are doing to your system and blindly clicking away is dangerous.

Instead i use the daily task found in /etc which in MAC OSX runs after 3am in the morning. I create a daily.local file because after the daily task is run the system recognises there is a another daily task to run and then straight away carries on to do the daily.local

HOW TO CREATE THE DAILY.LOCAL FILE

1.Open terminal found in /Applications/Utilities

2.Switch to root user (make sure you have root user enabled) by sudo su and type in the password

3. In the terminal window type

cd /etc/

4.type the following which will create the blank file

touch daily.local

5. type

vi daily.local

6.Press "i" for insert

7.type

#!/bin/bash

# Empty all User Trash Files

sudo rm -rf /Users/*/.Trash/*

# End

8.Press "Escape"

9. hold the "shift key" down and press ":"

10. then type wq! and press enter which is saying write and quit

11. then type

chown root:wheel daily.local and press enter

12. Then to make it executable type

chmod 755 daily.local and press enter

13. Thats it set the machine to wake at 3am and shut down later something like 6am and if you have workgroup manger you can do it from that and all the User .Trash files will automatically delete in the early hours of the morning without you having to do anything.

You can distribute the daily.locl file through Apple Remote Desktop or see my other thread here to package it up using xcode tools and Composer i used Composer 5.1 (the only version to retain resource and file forks)

http://www.mozdev.org/pipermail/systemproxy/2008-December/000007.html

you can use the daily.local task to carry out other task at night as well. Here is mine which does the following

1.Carries out a clean up script
2.Repairs Disk Permissions on the disk
3.Removes all user .Trash files
4.carries out a sophos antivirus scan of the disk
5.Sets the software update server to my dedicated xserve
6.Installs all of my authorised apple software updates

-----------------------

# Run cleanup script
echo "Running cleanup script"
sudo sh /Library/Scripts/.cleanup.sh
# End cleanup script

# Begin Repair Permissions Script
PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/libexec
export PATH
host=`hostname -s`
echo "Repairing Permissions on System Drive"
diskutil repairPermissions /
# End Repair Permissions Script

# Remove all User Trash Files
sudo rm -rf /Users/*/.Trash/*
# End Removing Trash

# Begin Sophos Sweep
sweep / --quarantine -exclude /Library/Management/Triggers
# End Sophos Sweep

# Set Softwareupdate Server
defaults write /Library/Preferences/com.apple.SoftwareUpdate CatalogURL http://xxx:8088/index.sucatalog
# End Setting SoftwareUpdate Server

# Begin Software Update
softwareupdate -i -a
# End Software Update
 
Back
Top