I have a media server running on OpenSolaris that is using Coherence to serve the media to the network. Sometimes I am having trouble on startup as the Coherence service fails to start because the lock file still exists (it was not cleaned up properly).

I want to know what is the best/neatest/most official way to delete this file on startup before the Coherence service attempts to start.

I thought about writing a quick script and putting it in /etc/rc3.d/ but I have read that OpenSolaris doesn't necessarily run scripts from that location.


Solaris uses SMF for managing services, but still supports the rc structure. Which way is Coherence started on your system? I would say that you need to use the same method for your lock-deleting script.

For documentation on the Solaris Service Management Facility (SMF) see this.

From that page:

Note that svcadm should only be used for SMF services -- legacy rc script-controlled services work the same as in past releases.


Services that are started by traditional rc scripts (referred to as legacy services) will generally continue to work as they always have. They will show up in the output of svcs(1), with an FMRI based on the pathname of their rc script, but they can not be controlled by svcadm(1M). They should be stopped and started by running the rc script directly.

As mentioned in the "Notable Changes" section, rc scripts may not run at exactly the same point in boot as they had in earlier versions of Solaris. In particular, scripts which depend on running before certain Solaris-provided rc scripts may encounter problems. The vast majority of scripts should continue to work without any trouble, though.

Coherence (Open)Solaris Installation Guide

  • Thanks for the reply. I am using Coherence as per the guide and using svcadm to enable/disable it etc. I've also found another solution which I've added an answer for. – Daemin Oct 14 '09 at 15:09

Just for information for future people.

I fixed my problem by modifying the coherence.sh script (which gets used by svcadm to start/stop the server), adding code to detect if the server was running and deleting the log file there if it was not.

The code inserted:

check() {
        if [ -f ${LOCKFILE} ]; then
            pgrep -f /usr/bin/$PROGNAME &> /dev/null
            [ ${RETVAL} -ne 0 ] && rm -rf ${LOCKFILE}
            echo ${RETVAL}
        return 0

Then I called this function from the beginning of the start() function and just before returning in the stop() function.

This will check if the executable is running and delete the log file if it is not. Seems to work fine and I haven't had any problems with it.

  • &> /dev/null would only work in bash. >/dev/null 2>& 1 works in any POSIX shell. – Henk Langeveld Aug 4 '12 at 22:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.