Skip to content

Instantly share code, notes, and snippets.

@nathanchere
Created April 4, 2017 10:04
Show Gist options
  • Save nathanchere/b3dd78cf05138b24147284fdf8776adf to your computer and use it in GitHub Desktop.
Save nathanchere/b3dd78cf05138b24147284fdf8776adf to your computer and use it in GitHub Desktop.
Check if current script is running in the foreground or background
#!/bin/bash
if [ -z `ps -o stat= | tail -n 1 | grep +` ]; then
echo 'Running in background!'
else
echo 'Running in foreground!'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment