Created
November 20, 2017 10:07
-
-
Save mackjoner/220c2519868d68a0b44818a7dc4e1f53 to your computer and use it in GitHub Desktop.
How to delete all (or most) jobs from a beanstalk tube from the shell
This file contains hidden or 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
#!/usr/bin/expect -f | |
# Filename: beanstalk-purge | |
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" | |
} | |
#Usage | |
#beanstalk-purge <host> <port> <tube> <count> | |
#Example | |
#beanstalk-purge 127.0.0.1 11300 snitch.site 35000 | |
#Delete the first 35,000 jobs out of the snitch.site tube on the beanstalk server located at 127.0.0.1:11300 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment