PDA

View Full Version : AppleScript for some cleaning job


jeno
February 2nd, 2009, 03:53 AM
Hello,

I am wondering how can write AppleScript to clean:
I am new to AppleScript and doesn't know which Services or OSAX or command or Framework to call.

-OS X Clipboard
-Virtual memory
-Paged memory

Thanks,
Jeno

Satcomer
February 2nd, 2009, 04:46 AM
Do you mean a cache clearing program like Yasu (http://jimmitchelldesign.com/projects/yasu/) or Onyx (http://www.titanium.free.fr/pgs2/english/download.html)? Also to understand the log clearing process read Running the Mac OS X maintenance scripts (http://www.thexlab.com/faqs/maintscripts.html). This will give you an idea on the log clearing process.

jeno
February 2nd, 2009, 04:49 AM
yup, sort of.

I want the script to be run in the background so that it will not interact with user.
Once the paged or Clipboard memory reach certain size, it will clean them automatically. :)

Giaguara
February 2nd, 2009, 02:50 PM
How about setting those cleaning tasks in cron?

jeno
February 2nd, 2009, 08:49 PM
cron script will be fine. May I know how to make one?

Giaguara
February 3rd, 2009, 03:49 AM
I forgot most of the cron (http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man1/crontab.1.html) and crontab (http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man5/crontab.5.html#//apple_ref/doc/man/5/crontab) tasks are with launchd (http://developer.apple.com/MacOsX/launchd.html). That launchd reference contains some advice for how to implement it and a few more links to programming.

jeno
April 8th, 2009, 10:44 PM
sorry to dig this up again.
correct me if i'm wrong. I did some reading on crontab and launchd. Its like setting up a "schedule" for some command to run. Now the question is, how am i going to write the actual command/instruction that is going to used for crontab and launchd?

Thanks

Satcomer
April 9th, 2009, 08:06 AM
Depends in 10.4.x it is Cron and in 10.5.x it is Launchd. Well it sounds as if you want to take a look at the donationware application Lingon (http://tuppis.com/lingon/).

Now most of the log rotation in 10.5 is already it OS X and they talk about that in the whole article Running the Mac OS X maintenance scripts (http://www.thexlab.com/faqs/maintscripts.html). Now clearing the Users Cache is another thing entirely and that is why I listed the freewarewares earlier in the thread (that also do the log rotating as a side benefit.

jeno
April 14th, 2009, 07:05 AM
Thanks for the tip Satcomer. I've downloaded Lingon for 10.4 and I am wondering how am I going to write some custom ProgramArguments. I am thinking of writing and adding in some custom command apart from the one that is already available. Some of the custom stuff I would like such as disconnect all mounted server if leave idea for 15 minutes. Cleaning the desktop after each reboot....etc

Cheers