Created
July 12, 2021 14:19
-
-
Save chakib-belgaid/6a45f723644c4f8701cabf2daa16f06c to your computer and use it in GitHub Desktop.
This file contains 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/sh | |
# a script that let you record the result of htop each $StepDuration in $ReportFile | |
##### HOW TO USE | |
## instead of CMD run recordtop.sh CMD | |
while getopts "d:o:" o; do | |
case "${o}" in | |
d) | |
StepDuration=${OPTARG} | |
;; | |
o) | |
ReportFile=${OPTARG} | |
;; | |
esac | |
done | |
shift $((OPTIND - 1)) | |
StepDuration=${StepDuration:-0.5} | |
ReportFile=${ReportFile:-$1'.report.htop'} | |
nohup $@ & | |
pid=$! | |
echo $pid | |
top -b -H -p $pid -d $StepDuration >$ReportFile & | |
wait $pid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment