2

We have some shell scripts that presently utilize Platform LSF to manage job execution.

These scripts will eventually be migrated to an environment that uses a different job scheduler.

During the migration phase it would be ideal to have the same script support job scheduling in both environments, so if it detects that the LSF environment is present, it uses LSF-specific instructions, else it uses the commands relevant to the other environment.

I've thought of a few possible solutions:

  • Check for LSF-specific environment variables

    e.g. $LSF_BINDIR, $LSF_LIBDIR, $LSF_SERVERDIR

    if [[ -n $LSF_BINDIR ]]; then
      # Yes LSF
    else
      # No LSF
    fi
    
  • Check for the availability of LSF-specific commands

    e.g. which bsub, which bhosts, which bjobs

    if [[ -z $( which bsub 2>&1 | grep "/usr/bin/which" ) ]]; then
      # LSF present
    else
      # LSF absent
    fi
    

I don't know if these checks are sufficient, or whether there is a better (as in less hacky), more reliable method for detecting the presence of Platform LSF on a system.

Zaid
  • 10,642

1 Answers1

3

It was a few years since I last used LSF, but the first command that is mentioned in the "LSF Batch User's Guide" (version 3.2) is lsid, which will display the name of the cluster and the name of the master host, as well as the version of LSF which is installed.

I think that checking for this command as well as for a couple of commonly used user utilities such as bsub and bjobs would be a good way of detecting LSF. I'm not aware of any other scheduling software that has this trio of utilities (but I'm no expert).

To check whether a command is in the current path, don't use which. Use command -v instead (see "Why not use "which"? What to use then?"):

if (command -v lsid && command -v bsub && command -v bjobs) >/dev/null; then
   echo "LSF seems to be available"
fi
Kusalananda
  • 333,661