Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Schedule Clearing Files from a drive that is being served

Hi All,


I'm charged with keeping our server and files maintained at work, and they have asked if I can schedule a weekly/monthly cleaning of the drive that is being served. I'm more of a designer then tech support, can anyone give me some ideas how I might do this?


I have all access admin priv.

I do use a mac everyday and I am familiar with the OS.

We are using a Mac Mini running 10.6.8 with Server 10.5 installed.

I don't have any apple scripting experience but am willing to try.


Thanks in advanced

Steve

Mac mini, Mac OS X (10.6.8), Server X 10.5 Installed

Posted on Aug 1, 2012 8:54 AM

Reply
Question marked as Best reply

Posted on Aug 1, 2012 12:53 PM

Before you go anywhere you need to define some basic parameters.


For example, what do you want/intend to 'clean up'?

It sounds like a dumb question, but it isn't.


No script can decide for you what your 'cleaning' should consist of - sure, it can find old files, or big files, or files with specific names, or in specific directories, or owned by specific users, or any number of other parameters, but you're the one that has to define the scope and the limit... HOW old? How big? What names?, etc.


Once you know what your rules are you can look at different implementation options, but as it stands there really isn't much you can do since your target is ill-defined.


Then you need to make sure your data is backed up properly. At some point, one day, ANY 'clean-up' task, whether manual or automated) is going to throw away a file that someone absolutely desperately needs. It's going to happen, and you will need a backup of your data that you can fall back to.


As a final thought, computers perform this task pretty awfully - there's often too much subjectivity in deciding what is worth keeping. Don't be surprised if your cleaning 'process' comes down to you dedicating an hour or two every week/month to take a look at what's there, rather than a headless automated script.

5 replies
Question marked as Best reply

Aug 1, 2012 12:53 PM in response to scoryell

Before you go anywhere you need to define some basic parameters.


For example, what do you want/intend to 'clean up'?

It sounds like a dumb question, but it isn't.


No script can decide for you what your 'cleaning' should consist of - sure, it can find old files, or big files, or files with specific names, or in specific directories, or owned by specific users, or any number of other parameters, but you're the one that has to define the scope and the limit... HOW old? How big? What names?, etc.


Once you know what your rules are you can look at different implementation options, but as it stands there really isn't much you can do since your target is ill-defined.


Then you need to make sure your data is backed up properly. At some point, one day, ANY 'clean-up' task, whether manual or automated) is going to throw away a file that someone absolutely desperately needs. It's going to happen, and you will need a backup of your data that you can fall back to.


As a final thought, computers perform this task pretty awfully - there's often too much subjectivity in deciding what is worth keeping. Don't be surprised if your cleaning 'process' comes down to you dedicating an hour or two every week/month to take a look at what's there, rather than a headless automated script.

Aug 1, 2012 4:09 PM in response to scoryell

OK... if that's what you want, it's trivial.


You can do it via AppleScript and the Finder:


tell application "Finder"

set oldFiles to every file of entire contents of disk "Volume Name" whose creation date is less than ((current date) - 30 * days)


deleteoldFiles

end tell


but the Finder is notoriously slow in dealing with large numbers of files and folders. If the disk is large (or, more correctly, if there is a large number of items on the disk) you may be better off with a shell command instead:


do shell script "find /Volumes/VolumeName -Btime +30 -delete"

Aug 3, 2012 10:20 AM in response to scoryell

So if I do this shell script, it will continue todo this until I excute another code to stop or is this code have to be ran everything I need it to work?

As written, the shell command will find files, delete them and then go away.

In the same way the AppleScript version will tell the Finder to find files and delete them, and then go away.


So both approaches will need some kind of schedule behind them if you want them to run automatically. launchd would be the presumed approach since it can launch any task on just about any schedule you like.

Schedule Clearing Files from a drive that is being served

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.