Skip to content

Instantly share code, notes, and snippets.

@eaguad1337
Created February 16, 2018 13:44
Show Gist options
  • Save eaguad1337/7eca3738cefc9b251189ad5a88f6f950 to your computer and use it in GitHub Desktop.
Save eaguad1337/7eca3738cefc9b251189ad5a88f6f950 to your computer and use it in GitHub Desktop.
Beanstalk Purge - Delete jobs from beanstalk
#!/usr/bin/expect -f
# Filename: beanstalk-purge
# Usage: ./beanstalk-purge $HOST $PORT $QUEUE $HOW_MANY
# Example: ./beanstalk-purge 127.0.0.1 11300 default 3000
set timeout 1
spawn telnet [lindex $argv 0] [lindex $argv 1]
sleep 1
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