ciphermethod.com

20131119: qpurge.sh

by on Nov.19, 2013, under Linux, Scripts

DO NOT USE: Use 20140218: qpurge.sh

#!/bin/bash

# Created 20131119 by Jamey Hopkins
# Cancel all jobs older than X days
# Example: qpurge 0 will cancel jobs not created on current day

if [ “$1” = “” ]; then
echo Enter days to cancel.
echo Example: qpurge 1
exit
fi

if [ `id -un` != “root” ]; then
echo “Need to be root.”
exit
fi

X=$1

echo “Total Jobs Before: `lpstat -o | wc -l`”

find /var/spool/cups/c* -daystart -mtime +$X >qpurge.tmp 2>/dev/null
for FILE in `cat qpurge.tmp`
do
basename $FILE | sed ‘s/c//g’ | xargs cancel
done

echo “Total Jobs After: `lpstat -o | wc -l`”

rm qpurge.tmp

No comments for this entry yet...

Leave a Reply

You must be logged in to post a comment.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

But Wait, There's More!

A few highly recommended friends...