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/stopping services from the command line

Starting/stopping services from the command line
Thread Tools
Tyre MacAdmin
Mac Elite
Join Date: Feb 2002
Status: Offline
Reply With Quote
Feb 14, 2006, 10:52 AM
 
Is there a way to start stop services from the commmand line in a format similar to Red Hat?

For instance:

service network stop

(stops the network)
     
[APi]TheMan
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status: Offline
Reply With Quote
Feb 14, 2006, 02:31 PM
 
Originally Posted by Tyler McAdams
Is there a way to start stop services from the commmand line in a format similar to Red Hat?

For instance:

service network stop

(stops the network)
Funny you mention it, because there is a "service" command on Mac OS X. It's a pretty simple command with hardly any documentation, but it works similarly to what you described (though I've never used Red Hat extensively). Check out the services it can control with sudo service --list.

The syntax is intuitive for stopping and starting and the man page details one or two other possible switches, for example:
Code:
[root@thefro: ~]# service --test-if-configured-on telnet [root@thefro: ~]# echo $? 1
Eh, check it out.
"In Nomine Patris, Et Fili, Et Spiritus Sancti"

     
Tyre MacAdmin  (op)
Mac Elite
Join Date: Feb 2002
Status: Offline
Reply With Quote
Feb 14, 2006, 04:48 PM
 
Thanks! Will do. Other than that, is there a "standard" way that OS X Server admin are taught to start/stop things like nfs, smb... etc from the shell?
     
Detrius
Professional Poster
Join Date: Apr 2001
Location: Asheville, NC
Status: Offline
Reply With Quote
Feb 17, 2006, 02:19 AM
 
Originally Posted by Tyler McAdams
Thanks! Will do. Other than that, is there a "standard" way that OS X Server admin are taught to start/stop things like nfs, smb... etc from the shell?
sudo serveradmin start smb

see:
man serveradmin

Doesn't work on client, though.
ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
[APi]TheMan
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status: Offline
Reply With Quote
Feb 17, 2006, 05:20 PM
 
Originally Posted by Detrius
sudo serveradmin start smb

see:
man serveradmin

Doesn't work on client, though.
Plus, the serveradmin command was pretty unintuitive the few times I tried to use it to control the firewall or afp. It seems like every time I try to use it the syntax varies so much from command to command (ipfilter, web, etc)... I wish managing services in Mac OS X server was more like in a Linux system with /etc/init.d scripts for starting, stopping, and restarting services.

Hell, a little shell script with some functions would be better. I didn't ever realize it, but that's all the StartupItems in Mac OS X were... Take this one I wrote for the syslog-ng daemon on one of my Mac OS X servers (Panther):
Code:
[root@server: /Library/StartupItems/syslog-ng]# cat syslog-ng #!/bin/sh ## # syslog-ng logging daemon ## . /etc/rc.common StartService () { ConsoleMessage "Starting syslog-ng" /usr/local/sbin/syslog-ng -f /etc/syslog-ng/syslog-ng.conf -p /var/run/syslog-ng.pid } StopService () { ConsoleMessage "Stopping syslog-ng" kill `cat /var/run/syslog-ng.pid` } RestartService () { ConsoleMessage "Restarting syslog-ng" StopService StartService } RunService "$1"
I just wish the serveradmin command was a little easier to use/understand.
"In Nomine Patris, Et Fili, Et Spiritus Sancti"

     
Detrius
Professional Poster
Join Date: Apr 2001
Location: Asheville, NC
Status: Offline
Reply With Quote
Feb 18, 2006, 03:54 PM
 
Originally Posted by [APi]TheMan
...I just wish the serveradmin command was a little easier to use/understand.
I never used the command line version. If I needed to control a server from another machine, I installed the Server Admin Tools on that other machine. As I recall, it's a free download from Apple.
ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
[APi]TheMan
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status: Offline
Reply With Quote
Feb 19, 2006, 03:53 PM
 
Originally Posted by Detrius
I never used the command line version. If I needed to control a server from another machine, I installed the Server Admin Tools on that other machine. As I recall, it's a free download from Apple.
Haha, totally true. I just get such a kick out of the command line. Plus, Apple's GUI tools can only do so much. I've noticed they're limited when it comes to configuring Apache and the Firewall, for instance.
"In Nomine Patris, Et Fili, Et Spiritus Sancti"

     
   
 
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 01:52 PM.
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.,