Batch delete specific folder from user home directories


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Batch delete specific folder from user home directories
# 1  
Old 09-06-2007
Batch delete specific folder from user home directories

Hi!

Need your help. How can I delete the cache folder of multiple user home directories via automatically executed shell script on a Mac OS X Server?

Example:

The userdata are stored on a Xsan Volume like this:

/Volumes/Xsan/userdata/mike
/Volumes/Xsan/userdata/peter
/Volumes/Xsan/userdata/robert
/Volumes/Xsan/userdata/dave
/Volumes/Xsan/userdata/michael

... etc. (total 1629 user home directories)

and in every userfolder is the same folder structur:

Desktop, Documents, Library, Movies, Music, Pictures and Public


The folder which should be removed is:

/username/Library/Caches


The script should go through all 1629 user home directories and delete the entire cache folder. If the folder don't exist it should ignore and go to the next task. I would like to run this script automatically as a cron job in the night.

Thanks in advance for your help.
# 2  
Old 05-09-2008
Try this. (Not exactly, but should work with minimum changes...)

for every_user in $(ls /Volumes/Xsan/userdata/*)
do
rm -r $every_user/Caches
done

Put this in a shell file and submit it to the cron.
# 3  
Old 05-09-2008
Code:
Find command can do this for u

find /Volumes/Xsan/userdata/ -name cache  -print | xargs rm -r

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Giving read write permission to user for specific directories and sub directories.

I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. This is for Solaris. Please help. (1 Reply)
Discussion started by: blinkingdan
1 Replies

2. Shell Programming and Scripting

Trying to delete a user and home directory

Good Afternoon, I'm trying userdel -r username on Solaris 9 and getting UX: userdel: ERROR: unable to find status about home directory: No such file or directory I see the user's home directory and getent passwd shows the user Anybody know what's causing it? (2 Replies)
Discussion started by: Stellaman1977
2 Replies

3. Solaris

How to unmount user home directories ??

I've allocated /exports for all user directories by making separate directories under /exports..... :rolleyes: now i need to unmount /exports . But i'm unable to do that.. How can i troubleshoot this issue. Thanks in advance:D (2 Replies)
Discussion started by: vamshigvk475
2 Replies

4. Homework & Coursework Questions

How to verify all user home directories are writable only by their owner

1. The problem statement, all variables and given/known data: Need to verify that all user home directories are writable only by their owner on Solaris. The script posted below is workable but it is taking a long time to display the results, and I don't seem to be able to fix it or find any... (6 Replies)
Discussion started by: NuuBe
6 Replies

5. Shell Programming and Scripting

How to verify all user home directories are writable only by their owner

Hi, I'm currently working on my school assignment on how to verify that all user home directories are writable only by their owner on Solaris with VMware. But I'm not sure why my codes take a very long time to display the results. My friend says it's the `su - $i -c "ls -ld" 2> /dev/null | grep... (1 Reply)
Discussion started by: NuuBe
1 Replies

6. Shell Programming and Scripting

Executing KSH batch file located in specific folder

Ok apologies if this is trivial or doesn't make sense but I am quite new to korn shells; So I have a .ksh batch file located in a folder of my choosing, I want to run this file in a korn shell. The problem though is that I want to get VBA code to do this. I have (VBA) code which opens command... (1 Reply)
Discussion started by: cjsewell
1 Replies

7. Shell Programming and Scripting

A Batch job to delete files from various directories

Hi, I have a shell script to find files older than 'X' days ($2) in directory path ($1) and delete them. Like this: my_file_remover.sh /usr/home/c 90 Now, I need to modify this script and add it in CRON, so that it checks other directories also. Like: my_file_remover.sh /usr/home/c... (3 Replies)
Discussion started by: guruparan18
3 Replies

8. UNIX for Dummies Questions & Answers

User home folder permissions catch-22, help!

Hi everyone. My objective is to configure a Solaris 10 box as follows: There will be many simultaneous users connecting to it, and each of those users would automatically get a home folder. For example, when I add user "Bob", the home folder would be /export/home/Bob And for Mary, it's... (3 Replies)
Discussion started by: EugeneG
3 Replies

9. UNIX for Dummies Questions & Answers

Delete old home directories

I have a script that deletes obselete users from /etc/passwd then moves their home directories to another location. After 30 days, I need to delete the home directories that were moved to the new location. I would appreciate any ideas on how to delete the directories after the 30 days? (2 Replies)
Discussion started by: munch
2 Replies
Login or Register to Ask a Question