Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Name of the app to monitor
- app_name="appname"
- # Function that verifies if the app is running
- check_process() {
- if pgrep -x "$app_name" > /dev/null
- then
- return 0
- else
- return 1
- fi
- }
- # Function to stop the app
- stop_process() {
- pkill -x "$app_name"
- echo "The process of $app_name was stopped"
- }
- # Loop to monitor and stop the application
- while true
- do
- if check_process
- then
- stop_process
- fi
- sleep 5 # Verify every 5 seconds
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement