Created
April 8, 2015 10:40
-
-
Save unicolet/af648a97163ce6b44645 to your computer and use it in GitHub Desktop.
Shell script to purge Rundeck execution history
This file contains 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
#!/bin/sh | |
# setup ~/.pgpass to allow passwordless connection to postgres | |
# keep last 30 executions for each job | |
KEEP=30 | |
cd /var/lib/rundeck/logs/rundeck | |
JOBS=`find . -maxdepth 3 -path "*/job/*" -type d` | |
for j in $JOBS ; do | |
echo "Processing job $j" | |
ids=`find $j -iname "*.rdlog" | sed -e "s/.*\/\([0-9]*\)\.rdlog/\1/" | sort -n -r` | |
declare -a JOBIDS=($ids) | |
if [ ${#JOBIDS[@]} -gt $KEEP ]; then | |
for job in ${JOBIDS[@]:$KEEP};do | |
echo " * Deleting job: $job" | |
echo " rm -rf $j/logs/$job.*" | |
rm -rf $j/logs/$job.* | |
echo " psql -h YOURDBHOST 'delete from execution where id=$job'" | |
psql -h YOURDBHOST -U rundeck rundeck -c "delete from execution where id=$job" | |
echo " psql -h YOURDBHOST -U rundeck rundeck -c 'delete from base_report where jc_exec_id=${job}::text'" | |
psql -h YOURDBHOST -U rundeck rundeck -c "delete from base_report where jc_exec_id=${job}::text" | |
done | |
fi | |
done |
Hello,
I have a problem with rundeck 3.0.23, using mysql 5.7 community edition
The first delete "delete from execution where id=$job" succeeds,
but the second "delete from base_report where jc_exec_id=${job}" fails with a constraint error :
ERROR 1451 (23000) at line 1: Cannot delete or update a parent row: a foreign key constraint fails (
rundeck
.referenced_execution
, CONSTRAINTFK3sv28w2o5i03gxi66b80240qk
FOREIGN KEY (execution_id
) REFERENCESexecution
(id
))
Have you a clue for fixing this ?
TIA,
Regards,
Xavier
…
On Wed, 10 Jul 2019 at 08:27, xavier8854 ***@***.***> wrote:
Hello,
I have a problem with rundeck 3.0.23, using mysql 5.7 community edition
The first delete "delete from execution where id=$job" succeeds,
but the second "delete from base_report where jc_exec_id=${job}" fails
with a constraint error :
ERROR 1451 (23000) at line 1: Cannot delete or update a parent row: a
foreign key constraint fails (rundeck.referenced_execution, CONSTRAINT
FK3sv28w2o5i03gxi66b80240qk FOREIGN KEY (execution_id) REFERENCES
execution (id))
Have you a clue for fixing this ?
TIA,
Regards,
Xavier
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/af648a97163ce6b44645?email_source=notifications&email_token=AAESIV5ODN67XVKK2C7EDT3P6V6NLA5CNFSM4HQCECJ2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFVBMO#gistcomment-2966215>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAESIV3WO5U43D6SNNRQCW3P6V6NLANCNFSM4HQCECJQ>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
Thanks for the script it really helps me, when i am using the same script it shows deleting jobs but it is keep on executing same steps it's not going to further.
echo " * Deleting job: $job"
rm -rf $j/logs/$job.*
Deleting job: 3104429
14:48:45 | | | rm -rf ./XYZ/job/81476133-1da6-40fc-7d3c-abf2caedd1f9/logs/3104429.*
Later it is failing with below timeout error after 2hr
15:29:20 | | | Result: 2147483647
15:29:21 | | | Failed: NonZeroResultCode: Result code was 2147483647
| ANY04210451 [console] |
15:29:21 | | | Cancellation while running step [1]
could you please help me what causes this issue. is this caused due to any permission issue ??
Thanks In Advance.
Regards,
Krishna