Stop FileMaker server from script

If you have a FileMaker system and you need to script the processing of adding or removing files on the server, the first problem you are going to come across is: how do I stop the server from a script?

You may already be familiar with the fmsadmin command. This is present on both Mac OS and Windows installs of FileMaker server. You can simply run the following command in Terminal to stop the server:

fmsadmin stop server

The difficulty is that this command normally expects a live user to key in some information to complete the command. In particular, a password must be supplied.

How do we stop the server from a script then?

fmsadmin -uYourAccount -pYourPassword -y -t300 stop server

Here we have supplied the user name and password, plus the -y option to answer that yes, we really want to stop the server, and -t to allow users up to 5 minutes to log off the database files.

Somewhat incongruously, to restart the server when done you simply use:

fmsadmin start server

No user or password is required.

Other Methods

On the Mac OS, if your script is running as root, you could’ve also used launchctl to stop the server:

launchctl stop com.filemaker.fms

The main downside to this is that you can’t specify a grace period to disconnect users. Also, if your script isn’t currently running as root, you’d have to use the sudo command to make command execute as root, and the expect command to supply a password to sudo.

For Windows, you do something similar to launchctl on OSX to stop the FileMaker database service:

net stop "FileMaker Server 8"

Kill Command

On OSX, you will almost never want to use the kill or killall command on the fmserverd process. If you do, the launchd daemon will almost immediately restart the server process. If for some you do need to use this command, perhaps because a server is not responding normally, perform in this order for best results:

sudo launchctl stop com.filemaker.fms
sudo killall fmserver_helperd
sudo killall fmserverd

Even more dangerous is to use kill -9, which is likely to cause any open files to be corrupted. If you must force quite the server, first disable or disconnect the network connection on the server, wait at least a minute, and only then force quite the fmserverd process. This should reduce the chances of your database being corrupted.

Leave a Reply