Skip to content

Instantly share code, notes, and snippets.

@sjchmiela
Last active August 29, 2015 13:55
Show Gist options
  • Save sjchmiela/8729188 to your computer and use it in GitHub Desktop.
Save sjchmiela/8729188 to your computer and use it in GitHub Desktop.
#!/bin/bash
trap 'date; exit' SIGINT # przed zakończeniem wypiszę datę
if [ -z $1 ]; then # jeśli pierwszy argument nie istnieje
ARG=10 # argumentem będzie 10
else
ARG=$1 # no chyba że istnieje
fi
if [[ $ARG -ge 60 ]]; then # jeśli sekund jest 60 lub więcej
MINUTES=`expr $ARG / 60` # wydzielam minuty
SECONDS=`expr $ARG % 60` # wydzielam sekundy
if (( $SECONDS > 9 )); then # i tworzę czas
TIME="$MINUTES:$SECONDS"
else
TIME="$MINUTES:0$SECONDS"
fi
else
if (( $ARG > 9 )); then # takoż tu
TIME="0:$ARG"
else
TIME="0:0$ARG"
fi
fi
while [ 1 ]; do
echo `ps aux | tail -n+2 | awk ' { print $10 } ' | awk -F. ' { print $1 } ' | awk ' {if(length("'$TIME'") < length($0) || "'$TIME'" < $0) { print $0 ; }}' | wc -l`
# procesy | odetnij | wypisz czasy | wypisz min:sek | jeśli długość ciągu czasu procesu jest większa od naszej lub porównując ciągi, procesu jest większy niż nasz: wypisz | policz
sleep 3
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment