if [ "$(pidof wallpaperRandomSwitch.sh)" ] ; then killall -9 -w wallpaperRandomSwitch.sh fi # add your code here exit while pidof wallpaperRandomSwitch.sh > /dev/null ; killall wallpaperRandomSwitch.sh ; done # add your code here exit