Searching running processes to get he PID, then killing it (The service will automatically restart).
Example
Code Snippet
- sudo ps -A | grep -i ssh
End of Code Snippet
23450 ?? S 0:00.12 /usr/sbin/sshd -i
23455 ?? S 0:00.03 /usr/sbin/sshd -i
23649 p8 S+ 0:00.00 grep -i ssh
Now use 'kill' on the PID...
Code Snippet
- sudo kill 23450
End of Code Snippet
Method 2
launchd is a unified, open-source service management framework for starting, stopping and managing daemons, applications, processes, and scripts. Written and designed by Dave Zarzycki at Apple, it was introduced with Mac OS X Tiger and is licensed under the Apache License.
We will be using launchctl, a subset of this framework to manage services...
List all services
Code Snippet
- launchctl list
End of Code Snippet
We can then use this list to identify the names of our services.
Here's an example with SSH...
Stopping a service
Code Snippet
- launchctl stop com.openssh.sshd
End of Code Snippet
Starting a service
Code Snippet
- launchctl start com.openssh.sshd
End of Code Snippet
No comments:
Post a Comment