This gist contains a solution to automatically shut down an Azure VM running a GitHub Actions self‑hosted runner when it has been idle for a specified period. It does so by monitoring the last modified time of the runner’s Worker logs in the _diag
folder. If no new Worker logs have been created for a set threshold (for example, 30 minutes), the script triggers a shutdown.
- check_idle_worker.sh
A Bash script that:- Scans the
actions-runner/_diag
directory for files whose names start withWorker_
.
- Scans the
- Calculates how long it has been since the most recent update.