#!/bin/bash

# Go to script directory
cd "`dirname $0`"

script_name="ecl_epics_envmon.py"

# Set up daq_slc
prev_pwd="$PWD"
cd ~/daq_slc; source setenv
cd "$prev_pwd"

# b2epics
export EPICS_CA_ADDR_LIST="172.22.63.255"

pkill -f "$script_name"

exec 2>&1

(
  # Add timestamps, output to log.txt
  exec 2>&1 > >(
    while read line; do
      date +"[%Y-%m-%d %H:%M:%S] $line" >> log.txt
    done
  )
  python "$script_name"
) & disown

