You could write your logs to a file whose name is based on:
- current date at the moment when you run the script
- current
PID of your program's instance
This should be enough to make sure each instance of your program has its own log file.
Here is a small example:
pid=$(echo $$) # Current instance PID
date=$(date +%s) # Seconds since Epoch
logfile="myscript.$date.$pid.log"
echo "I'm a log" > $logfile
echo "I'm another log" >> $logfile
If you want to include the name of the process that triggered your script, you could pass it as an argument to your script, like this:
myscript.sh
parent="$1"
pid=$(echo $$)
date=$(date +%s)
logfile="myscript.$date.$pid.$parent.log"
echo "I'm a log" > $logfile
echo "I'm another log" >> $logfile
You would call this script like this:
sh myscript.sh parent_script_name
And it would create a file similar to this one:
myscript.1518358314.85866.parent_script_name.log
echoorprintcommands before your actual commands so that you could track where the script is on current time, let me know if this helps you, I will post same thing on answer then.output_of_script_11_FEB_2018_9AM.txtetc. or you meant something else?