Skip to content

Instantly share code, notes, and snippets.

@shamil
Last active March 24, 2023 20:02
Show Gist options
  • Star 26 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save shamil/1f6524f06210252c7d13d0deb169bdc2 to your computer and use it in GitHub Desktop.
Save shamil/1f6524f06210252c7d13d0deb169bdc2 to your computer and use it in GitHub Desktop.
Rundeck executions cleanup
#!/bin/bash -e
# see related issue: https://github.com/rundeck/rundeck/issues/357
# export required vars
export RD_URL=http://localhost:4440 RD_USER=admin RD_PASSWORD=admin RD_HTTP_TIMEOUT=300
# make sure rd & jq commands are in the PATH
which -- rd jq >/dev/null
del_executions() {
local project=$1
while true; do
rd executions deletebulk -R -y -m ${RD_OPTION_BATCH:-20} --older ${RD_OPTION_OLDER_THAN:-3d} -p $project || break
sleep 1s
done
}
# delete executions for each project
for p in $(RD_FORMAT=json rd projects list | jq -r .[]); do
del_executions $p
done
exit 0
@erik-stephens
Copy link

@devinnasar, try -R:

[--require -R] : Treat 0 query results as failure, otherwise succeed if no executions were returned

@barkingfoodog
Copy link

Very helpful script, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment