20131119: qpurge.sh
by dervish 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
Leave a Reply
You must be logged in to post a comment.