Great thanks! So all could be done via Terminal. Will see if I can figure out how to use a Terminal script to automize this or would that be not graceful for shutting down? I thought of a sequence closing all files then testing if all closed then proceeding with terminating all involved?
if you find a reliable way of determining when FMS has completed shutdown, so that it can be issued the start command, I'd be interested. I've been failing to get a shell script to do this accurately for a long time. I've resorted to a long pause which gets the job done but it annoys me that I don't have a better way.
In case it's of use to someone, here's a PDF file with the FMSAdmin Command Line commands. It can be gathered from within Terminal as well, of course (fmsadmin HELP [OPTIONS]), but I like having it as a document. This is from FMS v16, but it's basically the same.
I normally just set a long time out - say four seconds before starting the service again.
We use web direct which is run under apache tomcat so the following works well.
ps aux | grep apache
and wait until there is no results.
The best way to do it would be to open the plist file as see what process it starts up - there might also be a default pid path - and then use `ps aux | grep {{processName}}
if nothing is returned then I start the process again.
I now however just use loop until the bash script can't find apache
#!/usr/bin/env bash
# Shutdown down FileMaker background services.
echo "/usr/bin/sudo /bin/launchctl unload /Library/LaunchDaemons/com.filemaker.fms.plist"
/usr/bin/sudo /bin/launchctl unload /Library/LaunchDaemons/com.filemaker.fms.plist
# Time to sleep between checks (in seconds)
SLEEP_DURATION=5
# We've noticed tomcat is running on our servers until
# the FileMaker background services are shutdown.
# Loop to continuously check for the Apache process
while true; do
# Check for the Apache process
if ! ps aux | grep -v grep | grep apache > /dev/null; then
echo "Apache process not found. Exiting."
exit 0
fi
# Sleep for the specified duration
sleep $SLEEP_DURATION
done
# Restart FileMaker background services.
echo "/usr/bin/sudo /bin/launchctl load -w /Library/LaunchDaemons/com.filemaker.fms.plist"
/usr/bin/sudo /bin/launchctl load -w /Library/LaunchDaemons/com.filemaker.fms.plist
The echo commands are there because I don't like magic scripts - I like to see what commands are actually being issued.