fix: scripts: (( )) returns 1 if evaluated to zero

This commit is contained in:
Stéphane Lesimple 2021-01-15 15:06:46 +00:00 committed by Stéphane Lesimple
parent 8d0004f8aa
commit 141791db92
2 changed files with 3 additions and 3 deletions

View file

@ -19,7 +19,7 @@ while read etimes pid tty
do
if [ "$tty" = "?" ] && [ "$etimes" -gt 86400 ]; then
tokill="$tokill $pid"
(( nb++ ))
(( ++nb ))
fi
done < <(ps -C ttyrec -o etimes,pid,tty --no-header)
if [ -n "$tokill" ]; then
@ -37,7 +37,7 @@ do
if [ "$tty" = "?" ] && [ "$user" != "root" ] && [ "$etimes" -gt 86400 ]; then
if [ "$(ps --no-header --ppid "$pid" | wc -l)" = 0 ]; then
tokill="$tokill $pid"
(( nb++ ))
(( ++nb ))
fi
fi
done < <(ps -C sshd --no-header -o etimes,pid,tty,user)

View file

@ -19,7 +19,7 @@ if [ "$1" = "--big-only" ]; then
do
if echo "$size" | grep -qE '^[0-9]+$' && [ "$size" -gt 100000000 ]; then
tokill="$tokill $pid"
(( nb++ ))
(( ++nb ))
fi
done < <(lsof -a -n -c ttyrec 2>/dev/null -- /home/ 2>/dev/null)
if [ -n "$tokill" ]; then