#!/bin/tcsh
#
# This script starts the Grouping Genetic Algorithm on a remote machine.
# It requires two parameters:
# 1. name of the remote machine
# 2. number of the config file (34a in config-34a.gga)
#
# Error-messages are reported to the file start. It also starts a crontab
# entry for the corresponding configuration. This entry uses the check shell
# script to determine if the gga should be restarted.
#
# Author: J.I.v.Hemert
#

rm -f ~/project/tools/cron
echo "0-59 * * * * nohup project/bin/check $2" >! ~/project/tmp/cron

rsh $1 "echo $1 ; cd ~/project/bin ; nohup ~/project/bin/gga ~/project/configs/config-$2.gga >&! ~/project/results/errors-$2& ; renice 15 %1 ; cd ~/project/tmp ; crontab cron" >>& ~/project/results/start &

sleep 8

if ("x`rsh $1 ps -u jvhemert | grep gga`" != 'x') then
	echo $2 $1 `date` >> ~/project/tools/list_of_running
else
	echo Looks like something has gone wrong, did not find a running gga
endif
