Skip to content

Instantly share code, notes, and snippets.

@TomA-R
Created July 16, 2018 23:59
Show Gist options
  • Save TomA-R/0edfb51f6e6c4716d2ac1820f0a582b0 to your computer and use it in GitHub Desktop.
Save TomA-R/0edfb51f6e6c4716d2ac1820f0a582b0 to your computer and use it in GitHub Desktop.
Purge beanstalkd tubes
# clean-beanstalkd.sh
#!/bin/bash
echo "list-tubes" | nc -C beanstalkd.host.example 11300 | grep pattern-example[0-9]-xyz | awk '{ print $2 }' > process-tubes.txt
while [ -s process-tubes.txt ]
do
while read line; do ./beanstalk-purge beanstalkd.ec2.edminfra.com 11300 $line 2; done < process-tubes.txt
echo "list-tubes" | nc -C beanstalkd.ec2.edminfra.com 11300 | grep [0-9].ssm-i | awk '{print $2}' > process-tubes.txt
done;
#!/usr/bin/expect -f
# Filename: beanstalk-purge
# From http://grahamc.com/blog/clear-all-beanstalk-jobs-in-a-tube/
set timeout 1
spawn telnet [lindex $argv 0] [lindex $argv 1]
sleep 0.05
send "use [lindex $argv 2]\n"
expect "USING"
for {set i 1} {$i < [lindex $argv 3]} { incr i 1 } {
send_user "Proccessing $i\n"
expect -re {.*} {}
send "peek-ready\n"
expect -re {FOUND (\d*) \d*}
send "delete $expect_out(1,string)\n"
expect "DELETED"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment