Skip to content

Instantly share code, notes, and snippets.

@tamebadger
Created February 2, 2014 06:09
Show Gist options
  • Save tamebadger/8763714 to your computer and use it in GitHub Desktop.
Save tamebadger/8763714 to your computer and use it in GitHub Desktop.
Shell scripts for controlling processes
#!/bin/bash
if pgrep
then
echo "exists";
else
echo "does not exist";
fi
#!/bin/bash
if pgrep -f '/usr/bin/mpd'
then
echo "running";
else
mpd &
sleep 2
pid=$(pgrep mpd)
sleep 10
echo $pid
kill $pid
fi
#!/bin/bash
pid=$(pgrep busftp)
while ps -p $pid; do
sleep 1;
done ; node /procedures/update.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment