#!/bin/sh

cd ~/online

if [ -r sktTrgReadout.lock ]; then

 echo "File sktTrgReadout.lock exists; cannot start sktTrgReadout"

else

 timestamp=`date +%s`
 nohup sktTrgReadout $@ 1> data/log/Log$timestamp.out_${HOST}Trg 2> data/log/Log$timestamp.err_${HOST}Trg &
 echo "Log file used: data/log/Log$timestamp.out_${HOST}Trg"

 rm ActiveLog.out_Trg
 rm ActiveLog.err_Trg
 ln -s data/log/Log$timestamp.out_${HOST}Trg ActiveLog.out_Trg
 ln -s data/log/Log$timestamp.err_${HOST}Trg ActiveLog.err_Trg

fi

sleep 1

if [ -r sktReadout.lock ]; then

 echo "File sktReadout.lock exists; cannot start sktReadout"

else

 timestamp=`date +%s`
 nohup sktReadout $@ 1> data/log/Log$timestamp.out_$HOST 2> data/log/Log$timestamp.err_$HOST &
 echo "Log file used: data/log/Log$timestamp.out_$HOST"

 rm ActiveLog.out
 rm ActiveLog.err
 ln -s data/log/Log$timestamp.out_$HOST ActiveLog.out
 ln -s data/log/Log$timestamp.err_$HOST ActiveLog.err

fi
