Open andreagalle opened 4 years ago
redirect stdout & stderr both to *.log file (eventually located within LOGDIR=./log/directory)
*.log
LOGDIR=./log/
nohup ./$2 >> $2.log 2>&1 & sleep 1 tail -f --pid=$(pgrep $2) $2.log
referring to: https://stackoverflow.com/questions/876239/how-to-redirect-and-append-both-stdout-and-stderr-to-a-file-with-bash
retrieving the correct pid not to fail when tail -f *.log according to the the top processes names length
pid
tail -f *.log
top
exe=$2 log=$2.log nohup ./$exe >> $log & job=${exe:0:15} tail -f --pid=$(pgrep $job) $log
redirect stdout & stderr both to
*.log
file (eventually located withinLOGDIR=./log/
directory)referring to: https://stackoverflow.com/questions/876239/how-to-redirect-and-append-both-stdout-and-stderr-to-a-file-with-bash
retrieving the correct
pid
not to fail whentail -f *.log
according to the thetop
processes names length