how to start/stop/restart processes

As a new comer from Windows OS, I wonder how to start/stop/restart a service on Mac OS X Snow Leopard 10.6.8 ?(it's straight forward on Windows using its Task Manager). I tried Activity Monitor, but it only kills processes, it does not start them. I tried the command: launchctl stop *servicename* and then the command launchctl start *servicename* after I hit return on keyboard after each command the terminal does not show any message so it must be successfull, but when I check out the result in Activity Monitor, it sounds that this command is useless because it has no effect on that process in Activity Monitor.

p.s. I'm sure I typed the right name of the process, I grabbed the name from the list using the command : launchctl list

EDIT: (ps auxwww command output lines)

line1:

zend 204 0.0 0.1 602396 2684 ?? Ss 10:53AM 0:00.72 /usr/local/zend/gui/lighttpd/sbin/lighttpd -m /usr/local/zend/gui/lighttpd/lib -f /usr/local/zend/gui/lighttpd/etc/lighttpd.conf -D

line2:

root 202 0.0 0.0 623124 756 ?? Ss 10:53AM 0:00.00 /usr/local/zend/bin/watchdog -c /usr/local/zend/etc/watchdog-lighttpd.ini -u zend -g zend -s lighttpd

Solution 1:

It is strange to see the questions between "windows migrated" and "default mac" users. :) Windows migrated users usually want "somewhat tweak" the system. Default Mac users - simply "using it".

I'm using MAC much years, and never needed to use the launchctl command. If mean never, mean in normal usage, of course sometimes needed use it when installing somethings from the macports - for onetime load of startup files or so.

I'm wondering, why you need start/stop/restart services with launchctl? Asking because if you not an experienced OS X users you probably will screw the system "harmony" :). So, in this case - IMHO - better to ask the specific problem, so ask how to start/stop the specific service.


As the answer - check first System preferences. Most common services are in the "Sharing" pane" - like web-server, sshd, CD sharing and so on...

Some third party dmg files with GNU stuff comes with own preference pane too. For example, you can install precompiled MYSQL server with a preference pane, what allow you start-restart the server.

If you don't find the wanted service in prefs, be more precise. What service you need start/stop? The "launchctl" command works as needed to work, ActivityMonitor too. You ofc can use "ps axuwww" or "top" commands from the Terminal too.

Remember, your now in the UNIX world, so nearly anything can be done from the command-line, but usually thats mean really much learning.. ;)


EDIT:

try:

sudo kill -1 204
              ^-process number

from the terminal, or simply kill the daemon from the ActivityMonitor. The watchdog should restart it.

Have you any lighthttpd file in the /Library/LaunchDaemons/*? So, any output form the command:

ls /Library/LaunchDaemons | grep -i light

if yes, you can use the:

sudo launchctl unload /Library/LaunchDaemons/filename.plist
sudo launchctl load /Library/LaunchDaemons/filename.plist

command for stop/start.

Solution 2:

I'm using MAC much years, and never needed to use the launchctl command. If mean never, mean in normal usage, of course sometimes needed use it when installing somethings from the macports - for onetime load of startup files or so.

I'm wondering, why you need start/stop/restart services with launchctl? Asking because if you not an experienced OS X users you probably will screw the system "harmony" :). So, in this case - IMHO - better to ask the specific problem, so ask how to start/stop the specific service.

I don't see a problem with asking the wider question as to how services are started and stopped if it enables the OP to better understand the underlying mechanics of the system.

As to why you would want to do this, one good reason would be to remotely kill errant processes on remote machines via Apple Remote Desktop. I do this frequently for our network users at school and it can save a lot of leg work (as well as avoiding entering repetitive terminal commands).

ARD users will want to kill processes by name rather than by PID as the process ID isn't necessarily the same each time the process is initiated...

sudo killall coreaudiod

...would be a useful command for ARD users as it's repeatable regardless of PID, whereas...

sudo kill -1 211

...would very likely only work to kill coreaudiod on the occasion that its PID was actually 211, and definitely wouldn't be an ARD command worth saving for future use. This may seem obvious to "advanced" users but unfamiliar users may not realise the difference.