andreagalle / .galledanza

User defined commands & env preferences to feel at Home Everywhere
MIT License
1 stars 0 forks source link

enhance sbag command #22

Open andreagalle opened 4 years ago

andreagalle commented 4 years ago
  1. redirect stdout & stderr both to *.log file (eventually located within LOGDIR=./log/directory)

    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

  2. retrieving the correct pid not to fail when tail -f *.log according to the the top processes names length

    exe=$2
    log=$2.log
    nohup ./$exe >> $log &
    job=${exe:0:15}
    tail -f --pid=$(pgrep $job) $log