A bash script to monitor and log a CLI application

I am doing Java this session and have done my assignment 4 for socket practices.

The assignment contains 2 parts: Client and server.

I can’t modify the assignment to have proper log details (e.g. add time to logs) because it will lose marks 🙁

So, I did a bash script named “run”.

#!/bin/bash
# Author name: Need-Being
# Modification date: 14/10/2011
trap "" SIGHUP
cd Server
java JavaQuizServer 2>&1 | while read LINE
do
        echo "`date '+[20%y/%m/%d-%T]'`[java] $LINE" >> ../JavaQuiz.log
done

“java JavaQuizServer” is the line to execute the program. I add the time before whatever it output and send it to “JavaQuiz.log”
‘trap “” SIGHUP’ is used for ignore signal SIGUP that it can be alive after closing it parent process i.e. ssh.
Continue reading A bash script to monitor and log a CLI application