Sometimes I need to delete lots of jobs from my beanstalk tube. In this particular case, I added 3
snitch.site jobs per site every day for the last few weeks. These jobs are how ZippyKid performs maintenance on Customer websites. Snitch reports the WordPress version in use, as well as updating ZippyKid specific configuration.
Since we were triple queueing each site, we weren’t able to keep up with the work. New sites were not getting updated in our client inventory system. No customers saw any issues, but our internal status portal’s data was stale. I stumbled across this graph of the snitch.site tube, and that explained it.
Now, Beanstalk doesn’t have a built-in way to clear out jobs en masse. I also wasn’t particularly interested in using a library to send a few basic commands.
Instead, what I came up with was a concise expect script. The script only uses tools installed on the vast majority of Linux systems:
beanstalk-purge <host> <port> <tube> <count>
beanstalk-purge 127.0.0.1 11300 snitch.site 35000
Delete the first 35,000 jobs out of the
snitch.sitetube on the beanstalk server located at 127.0.0.1:11300