Created
June 28, 2020 19:27
-
-
Save joelhoro/bf244e13cb561a4a7ef26417f3aeb102 to your computer and use it in GitHub Desktop.
Run file and redirect output to logfile w pid in its name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
basedir="/home/joel/processes/log" | |
export PYTHONUNBUFFERED=1 | |
logfile=$(date +%H%M%S.%N) | |
oldname="$basedir/log-$logfile.log.tmp" | |
#echo "Old name: $oldname"& | |
echo "$2" > $oldname | |
echo $(pwd) >> $oldname | |
$2 &>> $oldname & | |
newname="$basedir/$1-$(date +%H%M%S)-PID=$!.log" | |
echo "Logging '$1' \"$2\" to $newname" | |
mv $oldname $newname | |
#less +F $newname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment