Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Empty network trashes on Server via the Terminal OS X Server
Since the days of ASIP, the option to empty the trashes made by users on the server is gone. So here is the terminal command to do it:
 % find /Volumes/ -name "Trash Can #*" -print0 | xargs -0 rm -Rf
Use it with cron to automate the task...
    •    
  • Currently 2.00 / 5
  You rated: 4 / 5 (8 votes cast)
 
[6,984 views]  

Empty network trashes on Server via the Terminal | 5 comments | Create New Account
Click here to return to the 'Empty network trashes on Server via the Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Empty network trashes on Server via the Terminal
Authored by: swanksalot on Feb 12, '04 11:43:30AM

I get permission denied when I try this (even with sudo invoked).



[ Reply to This | # ]
Empty network trashes on Server via the Terminal
Authored by: bradhenry on Feb 12, '04 12:20:14PM

If you are trying to run on mounted filesystems that are not exported as root, sudo (to the root user) won't work.
If all the files are owned by user foo, then sudo -u foo would work.



[ Reply to This | # ]
Run all parts of a pipe as root
Authored by: kiwi23 on Feb 13, '04 06:16:54PM

If you want to run the whole pipe as root, not only the part leading up to the | (pipe) symbol, then you need to do

sudo /bin/bash -c '<your commands here>'

for the original command line it would read

sudo /bin/bash -c 'find /Volumes/ -name "Trash Can #*" -print0 | xargs -0 rm -Rf'

This is because the shell will split the command line at the | so that the sudo will only see the first part. The commands following the | will be run under your account, not under sudo's control. The solution presented runs a whole shell as root. This shell then runs both commands of the pipe as root.



[ Reply to This | # ]
Empty network trashes on Server via the Terminal
Authored by: seann on Feb 12, '04 02:56:32PM

Odd..
Last night I wrote a script to clean up the 10.2 server I maintain.

find /Volumes/ -name ".DS_Store" -delete
find /Volumes/ -name "Desktop DB" -delete
find /Volumes/ -name "Desktop DF" -delete
find /Volumes/ -name ".Trashes" -delete
find /Volumes/ -name "Network Trash Folder" -delete
find /Volumes/ -name "TheFindBy*" -delete

and it runs every night.



[ Reply to This | # ]
Empty network trashes on Server via the Terminal
Authored by: sapridyne on Feb 13, '04 12:21:19AM

Cool! I've been meaning to set up something that will do this, but it always got pushed down to the bottom of the list. Thanks for the hint!



[ Reply to This | # ]