I use the Skype and Adium clients on my Mac at work. I have two scripts (Ruby, if it matters), start_chats
and kill_chats
that start/kill both applications. These scripts are both executable and work fine from the command line. I used to use cron in Snow Leopard to run these scripts at scheduled times: start_chats
at 8:00 when I come in to my office, and kill_chats
to kill them (thus, logging me out of all connected accounts) at 6:00 (18:00) after I leave my office.
Since I recently got a new machine with Lion on it, cron acts really flaky and more often than not, does not execute its jobs at all (I have other jobs in the same crontab). So, in trying to keep up with technology, I decided I'd try to rework this using launchd
plists. I've looked through many "tutorials" and whatnot on how to construct a plist to do a simple clock-based execution of my scripts. The problem with most of these tutorials is that they don't really tell what to do after you've created the plist. Here is my sample kill_chats
plist (built with help from this post):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>local.me.kill_chats</string>
<key>OnDemand</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Users/me/bin/kill_chats</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>18</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
</dict>
</plist>
Yes, it is named local.me.kill_chats.plist
and I put it in my ~/Library/LaunchAgents/
directory. Note that I've also tried to use the Program
key as well, but that didnt' work either. If I run
$> launchctl load ~/Library/LaunchAgents/local.me.kill_chats.plist
it says the list is already loaded, and indeed I can see it in
$> launchctl list | egrep kill_chats
- 0 local.me.kill_chats
But when my system clock hits the time specified in the plist, my kill_chats
script is not being run. Of course I'm not waiting until 18:00 to test it every time, so I change it to a few minutes ahead of whatever the current time is, but it's still not executing the script. I've even tried Lingon (the older, free version), but nothing seems to work.
Am I doing something wrong? Is something wrong with my plist? As I said, I've looked through a bunch of different sites (even numerous Stackexchange posts) and my list seems to be correct. I'm just not sure how to make "it" "use" my list. Any help would be greatly appreciated.
(Note: admins, feel free to migrate this to Apple or Superuser if necessary)