There are a few really simple methods:
pgrep procname && echo Running
pgrep procname || echo Not running
killall -q -0 procname && echo Running
pidof procname && echo Running
More Related Contents:
- How do I tell if a regular file does not exist in Bash?
- How can I check if a program exists from a Bash script?
- How can I compare numbers in Bash?
- echo “#!” fails — “event not found”
- Pipe output and capture exit status in Bash
- Redirect stderr and stdout in Bash [duplicate]
- Which characters need to be escaped when using Bash?
- bash : Illegal number
- Shell redirection i/o order
- Loop through all the files with a specific extension
- Passing arguments with spaces between (bash) script
- Colorized grep — viewing the entire file with highlighted matches
- How to pass in password to pg_dump?
- How can I profile a Bash shell script slow startup?
- Select random lines from a file
- Variables getting reset after the while read loop that reads from a pipeline
- How can you run a command in bash over and over until success?
- Sleep until a specific time/date
- Minimal web server using netcat
- How to delete and replace last line in the terminal using bash?
- Passing arguments by reference
- How to limit number of threads/sub-processes used in a function in bash
- How do I remove all .pyc files from a project?
- Sorting strings with numbers in Bash [duplicate]
- Get current directory or folder name (without the full path)
- What does the double-asterisk (**) wildcard mean?
- Pipe output to two different commands [duplicate]
- Using cut command to remove multiple columns
- How to send control+c from a bash script?
- How to properly nest Bash backticks