Welcome to the navigation

Nulla veniam, exercitation occaecat magna nostrud lorem aliqua, eiusmod duis minim in cupidatat aliquip id proident, qui officia amet, dolor sint pariatur, cillum consequat, in. Ipsum non amet, quis sint nostrud esse proident, ex culpa deserunt dolore reprehenderit est irure commodo mollit fugiat ut velit id eu magna dolor veniam

Yeah, this will be replaced... But please enjoy the search!

Restart all running services in OS X Server

Categories Tags
In some Linux distributions it's possible to restart all running services by typing
$/sbin/services.sh restart
This guide will help you to create an equivalent command in OS X Server. This should work on pretty much any OS X server version, but I have only tested it in Leopard Server and Snow Leopard Server.

First things first

Start by creating the script, I prefer nano but pretty much any text editor will do
$nano ~/Documents/serviceRestart
Paste this text into the script
# /bin/sh
echo "--- Script start ---"

# Create the array
services=( $(sudo serveradmin list) )

# Make the masterloop
for eachService in ${services[@]}; do

  # Check the status of the current service listed in the array
  tc=$(sudo serveradmin status $eachService | grep -io "RUNNING")

  # If the service is running, then restart it, we wont touch other services
  if [ "$tc" = "RUNNING" ]; then
    echo $i $eachService "(RUNNING)"
    sudo serveradmin stop $eachService && sudo serveradmin start $eachService
  fi

done
echo "--- Script end ---"
# /bin/sh
"--- Script start ---"
dd execute rights to the script
$sudo chmod +x ~/Documents/serviceRestart
And link the script into /usr/bin for easy execution
$sudo ln -s ~/Documents/serviceRestart /usr/bin/

Running the script

Open the terminal and enter
serviceRestart
The sudo command inside the script might ask for your password. This is normal. Good luck!
Please note that this portal is a BETA site , I will continuously improve all functionality and performance during the coming weeks / the author