#!/bin/bash # Description: # This script aids management of condor compute nodes. The script # takes a command as an argument and waits until condor_startd is # not running before executing the command. # Use with: condor_off -peaceful # Original verions TDR Feb 29, 2008 # Change to looking at startd TDR Mar 17, 2008 # Seems that when you specify that the master be shutdown, # a gracefully instead of peaceful shutdown is done. # So we don't want to shutdown the master and instead this # script should look at condor_startd # ends jobs. Should do: condor_off -peaceful and # then wait for condor_startd to go away #Usage: # condor_waiter {command} # command should be specified as one argument (put it in quotes) if [ "$#" -eq "0" ]; then echo echo Usage: echo condor_waiter '{command}' echo ' command should be one argument (put it in quotes)' exit 1 fi # if not launched with --child option, relaunch in background if [ "x$1" != "x--child" ]; then $0 --child $@ >> /tmp/condor_waiter.$$.out 2>&1 & exit 0 fi # shift off the --child option shift # really want to look at startd, TDR Mar 17. startd_pid=`ps h -o pid -C condor_startd` if [ "$?" -eq "0" ]; then timestart=$(date -u +%s) logger -s -- condor_waiter $$: condor_startd $startd_pid is running waiting for it to end before executing: $@ # wait for condor_master to go away # kill -0 is just a way to check if the process is alive while kill -0 $startd_pid 2> /dev/null; do sleep 10; done timeend=$(date -u +%s) logger -s -- condor_waiter $$: condor_startd $startd_pid has gone away after $((timeend-timestart)) secs will now execute: $@ else logger -s -- condor_waiter: condor_startd was not running will now execute: $@ fi # finally do it $@ exit 0