I really hate it when people start messing with the way that services are handled on proprietary unix systems. Sun's svcs framework, and Apple's use of launchctl. I got a quick lesson from a buddy of mine today regarding the latter. Starting and stopping services with launchd is not difficult, but some of the terminology is counter intuitive.
What I really wanted to do was to restart sshd to improve security, after a rather alarming look at my /var/log/security log. After making the changes to the sshd_config, I found myself baffled. Here's a quick launchd lesson:
To list services managed by launchd:
launchctl list
[root@gordon:etc]# launchctl list | grep ssh
15736 - 0x100601f70.anonymous.sshd
15831 - 0x10051e770.anonymous.sshd
15829 - 0x100401eb0.anonymous.sshd
15734 - 0x1006018d0.anonymous.sshd
10259 - 0x10051e4b0.anonymous.sshd
10241 - 0x100101ae0.anonymous.sshd
10235 - 0x100101820.anonymous.sshd
- 0 com.openssh.sshd
You'll need the launchd string for anything else you want to do. Incidentally, everything here with a hex number at the beginning is a child process, which you can pretty much ignore.
To restart a launchd-managed service:
launchctl stop [Label]
launchctl stop com.openssh.sshd
Note that "stop" actually means stop the running instance. Launchd will automatically restart the service.
To stop a launchd-managed service:
launchctl unload [Label]
launchctl unload com.openssh.sshd
"Unload" causes the service to be stopped, and not restarted by launchd. This change is not persistent, and the service will be started again on the next system reboot.
To stop a launchd-managed service, and prevent it from starting on the next system boot:
launchctl unload -w [Label]
launchctl unload -w com.openssh.sshd
I'm just using sshd as an example here - this would actually make you pretty unhappy if you did this remotely.
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment