Welcome to the navigation

Nulla magna dolore veniam, laborum, deserunt ad minim cupidatat mollit anim reprehenderit in ullamco cillum lorem qui sunt labore dolor duis sint id ex excepteur. Aliqua, culpa mollit magna ut reprehenderit dolore esse do lorem dolore nulla anim velit sit laborum, voluptate enim sed aute exercitation consectetur eu sunt ut

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!