PDA

View Full Version : com.apple.batteryd.plist removal Question




Quad5Ny
Jan 22, 2011, 03:00 AM
I have a new MacBook Air and it came shipped with a bogus plist (com.apple.batteryd) that had launchd going nuts. Launchd was trying to run /usr/local/libexec/batteryd every 10 seconds, stopping the computer from sleeping and spamming the system log.

Edit: For reference, this was what was being spamed in the system log every 10 seconds:
1/13/11 11:09:31 PM com.apple.launchd[1] (com.apple.batteryd[1114]) Exited with exit code: 1
1/13/11 11:09:31 PM com.apple.launchd[1] (com.apple.batteryd) Throttling respawn: Will start in 10 seconds
1/13/11 11:09:41 PM com.apple.launchd[1] (com.apple.batteryd[1115]) posix_spawn("/usr/local/libexec/batteryd", ...): No such file or directory

So I went into Terminal and typed ' sudo rm "/System/Library/LaunchDaemons/com.apple.batteryd.plist" ' and everything is as it should be, but I just noticed Apple released a update that's meant to fix this. - http://support.apple.com/kb/DL1354 (Which is weird because the update is for 10.6.5 and I was having trouble with 10.6.6).

After going through the update files I noticed Apple's method of removing the file was much more complex.

Apple's Method for removing com.apple.batteryd.plist:
#!/bin/sh

if [ -e "$3/System/Library/LaunchDaemons/com.apple.batteryd.plist" ]; then
sudo launchctl unload "$3/System/Library/LaunchDaemons/com.apple.batteryd.plist"
rm -rf "$3/System/Library/LaunchDaemons/com.apple.batteryd.plist"
fi

Could just deleting the plist like I did cause any harm?



lucashungaro
Jan 22, 2011, 06:51 AM
Actually, what these lines are doing is: checking if the file exists, unloading it from the system (stoping the process) and, then, removing it. If you managed to remove it without issues, it was not running (or the system would complaint) and all is fine.

BeyondtheTech
Jan 22, 2011, 06:53 AM
From what I can tell, Apple's script basically told launchd to stop trying to access the file, then delete the actual file.

What you did was just delete the file, but not stop launchd from trying to run it.

You should run the command as recommended.

Quad5Ny
Jan 22, 2011, 07:26 AM
Actually, what these lines are doing is: checking if the file exists, unloading it from the system (stoping the process) and, then, removing it. If you managed to remove it without issues, it was not running (or the system would complaint) and all is fine.
From what I can tell, Apple's script basically told launchd to stop trying to access the file, then delete the actual file.

Thanks guys.

I was mostly curious about 'launchctl unload' and the -r option for rm - The manual page says it 'Attempt's to remove the file hierarchy rooted in each file argument' - which confused me a bit. :p

What you did was just delete the file, but not stop launchd from trying to run it.

You should run the command as recommended.

Unfortunately the update wasn't out at the time and I did the best with the information I had (basically a few posts on Apple's Forums). I'll do the unload command when I get on my Air later today, but my log's have been clear of any errors relating to batteryd.