Last active
January 6, 2026 03:53
-
-
Save henri/da501834117110f614ffdc0f21ea2434 to your computer and use it in GitHub Desktop.
long running process bash monitoring process PID and time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # | |
| # Create a long running process which may be used for experimentation | |
| # | |
| # | |
| # check how long a process is running in seconds | |
| # ps -p <PID> -o etimes= | |
| # | |
| # generic | |
| # ps -p <PID> -o pid,comm,etime | |
| # | |
| # pgrep --full <process name> | |
| # | |
| # | |
| # note : this implimentation has no support yet for catching interupts / signals | |
| # | |
| total_run_time_seconds=0 | |
| while true; do | |
| echo "PID $$" | |
| echo "Running... press Ctrl+C to stop" | |
| sleep 60 | |
| total_run_time_seconds=$((total_run_time_seconds + 60)) | |
| echo " Running for $total_run_time_seconds" | |
| done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment