Skip to content

Instantly share code, notes, and snippets.

@bartread
Created January 21, 2017 13:01
Show Gist options
  • Save bartread/c2b94ac871f47c61974460bb618f5827 to your computer and use it in GitHub Desktop.
Save bartread/c2b94ac871f47c61974460bb618f5827 to your computer and use it in GitHub Desktop.
Ubuntu 16 - reliably find node processes and take conditional action
#!/bin/sh
NODEPROCESSES=$(ps -aux | grep '[s]udo nohup node index.js' | awk '{print $2}')
if [ -n "$NODEPROCESSES" ]; then
echo "Found node processes $NODEPROCESSES"
else
echo "No node processes found"
fi
@bartread
Copy link
Author

Of course, this presupposes node has been run as a background process from directly from a shell, or from a shell script, rather than as a service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment