I use Skype and Adium clients on my Mac at work. I have two scripts (Ruby, if that matters), start_chats and kill_chats that start / kill both applications. These scripts are executable and work fine from the command line. I used to use cron in Snow Leopard to run these scripts on a schedule: start_chats at 8:00, when I get to my office, and kill_chats to kill them (thus, get me out of all connected accounts) at 6:00 ( 18:00) after my departure.
Since I recently received a new machine with Lion on it, cron is really flaky and most often it doesn’t do its job at all (I have other jobs in the same crontab). Therefore, trying to keep up with the technology, I decided that I would try to rework it with launchd plists. I looked through a lot of “tutorials” and once again on how to build a plist to easily run my watch-based scripts. The problem with most of these tutorials is that they don’t say what to do after creating the plist. Here is my kill_chats plist sample (built using 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 called local.me.kill_chats.plist , and I put it in my ~/Library/LaunchAgents/ . Note that I also tried to use the Program key, but that didn't work either. If I run
$> launchctl load ~/Library/LaunchAgents/local.me.kill_chats.plist
he says the list is already loaded, and indeed, I see it in
$> launchctl list | egrep kill_chats - 0 local.me.kill_chats
But when my system clock reaches the time specified in plist, my kill_chats script does not start. Of course, I do not wait until 18:00 to check it every time, so I change it a few minutes earlier than anything, but it still does not execute the script. I even tried Lingon (an older, free version), but nothing works.
Am I doing something wrong? Is there something wrong with my plist? As I said, I looked at many different sites (even a lot of Stackexchange messages), and my list seems to be correct. I'm just not sure how to make this "use" my list. Any help would be greatly appreciated.
(Note: administrators, feel free to port this to Apple or Superuser if necessary)