Applescript to kill an application or process and restart

May 31st, 2011 by hamlesh No comments »

Another bit of AppleScript hackery, this one will kill a defined application / process based on a defined schedule (every x hours) and restart the application / process after a slight delay.

repeat
delay 7200
set app_name to "PROCESS NAME"
set the_pid to (do shell script "ps ax | grep " & (quoted form of app_name) & " | grep -v grep | awk '{print $1}'")
if the_pid is not "" then do shell script ("kill -9 " & the_pid)
delay 30
tell application app_name to activate
end repeat

You can find the application / process name by looking in Activity Monitor app.

Tweak the first delay parameter (in seconds) to suit your needs – the above will kill and restart the application / process every 2 hours (with a 30 second delay in-between killing and restarting).

Found this useful? Why not become a fan on facebook, or say hello on twitter?

Applescript to check for a process and restart it (heartbeat)

May 26th, 2011 by hamlesh No comments »

Recently had an issue where an application / process I would leave running on my macbook overnight would crash and stop running.  I needed a way to automatically restart the application / process if it wasn’t running, having a never ending spooling loop wouldn’t work (and is a nasty way to do it).

So I came up with the following AppleScript code.

Copy and paste into AppleScript Editor, make the changes you need, and save it as an “Application”.  Remember to tick “Stay Open” when you save it.  I’ve dropped, what i’ve called the “Heartbeat App” onto the dock and set it to start when the computer does.

repeat
delay 60
set core_is_running to is_running("NAME OF PROCESS OR APPLICATION")
if core_is_running is false then
tell application "NAME OF PROCESS OR APPLICATION" to activate
set core_is_running to is_running("NAME OF PROCESS OR APPLICATION")
end if
end repeat
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running

delay 60 is the time interval in seconds you’d like the heartbeat app to check for the application or process.

To find out the NAME OF PROCESS OR APPLICATION, simply run the application / process, then look under Process Name in Activity Monitor.

You could also adapt this to run an application / process every x amount of time if you so wished.

Comments, becoming a fan on facebook, and saying hello on twitter, always appreciated :)

Equinix commits to use 50% renewable energy in Paris data centres – Not 100% true

May 16th, 2011 by hamlesh No comments »

I thought i’d post a quick comment on something that broke on the wires this morning / last night.

Fundamentally, what Equinix (EQIX) have done is purchase 45,000 of EDF’s Certificats Equilibre (CEs).

Taken directly from the press release;

For every ‘Certificats Equilibre’ purchased, EDF injects one MWh of power from renewable sources into its network.

The key point here is “into its network” – this doesn’t mean EQIX’s network, it means EDF’s network/grid.

Therefore this does not mean that 50% of the power used by the EQIX datacenter is renewable, it means that the power provider used by EQIX, in this case EDF, has 45GWh of power on-stream from renewable sources.

Granted the Paris EQIX facility uses about 90GWh of power, and so 45GWh of that is coming from a provider who has 45GWh of power on-stream from renewable sources.  This is not what the press release claim is though, bad wording.

A more accurate headline “EDF commits 45GWh of power from renewable sources thanks to Equinix“.

Doesn’t quite have the same punch, but much more accurate.

2032 Apple Mac OSX fonts to download

May 12th, 2011 by hamlesh No comments »

I’ve created a collection from around the internet of 2032 Apple Mac fonts, these will work on OSX.  Every once in a while i’ll refresh the collection, so you should search on here for newer posts similar to this one.

For now, heres the download link: http://www.mediafire.com/?869f9bj1399bsc0 (55.29 Mb)

You’ll need a password to download, which is really simple to obtain;

Pay with a tweet

1. Follow @hamlesh on twitter

2. Click here to pay with a tweet

3. I’ll reply via DM to you with the password

Via Paypal

1. Click here to pay via PayPal (its only £1)

2. I’ll reply via email with the password

My replies aren’t automated, so bare that in mind.

To install the fonts in one go, once you’ve extracted the zip file, copy them to your “~/Library/Fonts” folder in your “home directory“.

Remote desktop RDP on Jolicloud

February 13th, 2011 by hamlesh 1 comment »

I’m currently using Jolicloud all the time on my workhorse netbook – the one that I take to clients sites / abroad / datacenters when consulting / doing bits of work. One annoying thing is the lack of a remote Windows Desktop Client. Searching the web shows this is a common problem, so heres how you install MS RDP.

  1. Press ALT + F1 at the same time
  2. Terminal window opens
  3. Type “sudo apt-get install tsclient” – you’ll get asked for your password
  4. Apt-get fetches the relevant packages and does the install
  5. To run the tsclient, simply open the terminal and type “tsclient”

Done :)

I need to work out how to add a custom icon to the dashboard, tweet me if you know how – i’ve not bothered to work that out yet.