reddit-image-wall-getter/cron_prerun_kill.sh

33 lines
711 B
Bash
Executable File

#!/bin/bash
attempt_interrupt() {
export TEST="$(ps -aux | grep './redditgetter.py' | grep -v grep | grep -v bash | sed -e 's/ */ /g' | cut -d' ' -f2)";
if [ -n "$TEST" ] ; then
echo "Killing...";
echo "$TEST" | xargs -rl1 -- kill -2;
sleep 1;
fi
}
force_interrupt() {
export TEST="$(ps -aux | grep './redditgetter.py' | grep -v grep | grep -v bash | sed -e 's/ */ /g' | cut -d' ' -f2)";
if [ -n "$TEST" ] ; then
echo "Force-Killing...";
echo "$TEST" | xargs -rl1 -- kill -15;
sleep 1;
fi
}
attempt_interrupt
attempt_interrupt
attempt_interrupt
attempt_interrupt
attempt_interrupt
attempt_interrupt
attempt_interrupt
attempt_interrupt
attempt_interrupt
attempt_interrupt
force_interrupt