Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Starting and stopping services

Starting and stopping services
Thread Tools
cruisereg
Fresh-Faced Recruit
Join Date: Oct 2006
Status: Offline
Reply With Quote
Oct 3, 2006, 07:32 PM
 
Is there a way to start and stop various OS X services from the CLI? There are a couple of configuration changes I'd like to make from roam from home to office to where ever. I'm talking about ssh, internet sharing (including switching what gets shared over what), file sharing, etc.

Any tips or pointers? I've haven't dug into this yet, thought I'd ask here first.

I'm an "old school" *ix guy that likes to have control for exactly these types of situations.

Thanks in advance.
2GHz MacBook w/2Gb RAM & 120Gb disk
     
maceye
Mac Enthusiast
Join Date: Dec 1999
Location: New York
Status: Offline
Reply With Quote
Oct 3, 2006, 08:48 PM
 
Are you sure you need to stop and start those services for changes to take effect? My best guess for restarting services would be to kill the process and then launch it from the terminal.

Maybe you could make an AppleScript script to modify whatever settings you want to change if there is no simple cli method. I'm assuming you are trying to automate changing these settings... I have not tried this myself, so I don't know if it's possible.
     
cruisereg  (op)
Fresh-Faced Recruit
Join Date: Oct 2006
Status: Offline
Reply With Quote
Oct 4, 2006, 01:52 AM
 
Originally Posted by maceye
Are you sure you need to stop and start those services for changes to take effect? My best guess for restarting services would be to kill the process and then launch it from the terminal.
No I'm not sure, but in general this is how things work on other unices. I'm assuming thats the case with OS X as well.

Maybe you could make an AppleScript script to modify whatever settings you want to change if there is no simple cli method. I'm assuming you are trying to automate changing these settings... I have not tried this myself, so I don't know if it's possible.
This is an option, but the CLI method doesn't have to be simple - I grok multiple scripting languages. I'll have to do a bit of research.
2GHz MacBook w/2Gb RAM & 120Gb disk
     
IEEE1394
Mac Enthusiast
Join Date: Dec 2000
Status: Offline
Reply With Quote
Oct 4, 2006, 08:00 AM
 
The web server can be restarted in the usual manner - "apachectl restart".

Try reading up on launchd, the Mac OS X daemon launcher and manager.
     
P
Moderator
Join Date: Apr 2000
Location: Gothenburg, Sweden
Status: Offline
Reply With Quote
Oct 4, 2006, 11:50 AM
 
General UNIX daemons reload changes if you send HUP to them, ie "sudo kill -1 pid" or "sudo killall -1 process_name". HUP will kill any normal process (that's what they get sent when you log out or close the parent terminal window), but a daemon will just restart.

For an intro to launchd and launchctl, try this

Getting Started with launchd
     
cruisereg  (op)
Fresh-Faced Recruit
Join Date: Oct 2006
Status: Offline
Reply With Quote
Oct 5, 2006, 03:01 PM
 
Originally Posted by P
General UNIX daemons reload changes if you send HUP to them, ie "sudo kill -1 pid" or "sudo killall -1 process_name". HUP will kill any normal process (that's what they get sent when you log out or close the parent terminal window), but a daemon will just restart.

For an intro to launchd and launchctl, try this

Getting Started with launchd
Very cool - I think this is what I was looking for. Thanks for the pointer. Its actually scary remembering signals after being away from real Unix admin jobs for nearly ten years.

Thanks again and I look forward to hopefully helping other people here.
2GHz MacBook w/2Gb RAM & 120Gb disk
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 06:24 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,