delete old print jobs
angelb
angelb at bugarin.us
Thu May 17 11:45:54 PDT 2007
> Is there an easy way to delete print jobs older than a certain date? I started going down the path of using lpstat -o |grep -v <date> but ideally I want to delete all jobs older than X days. We tend to get jobs that sit out there for weeks or longer. Thanks for any help you can offer.
>
> --
> Amy Tanner
> amy.tanner at netaspx.com
I had a simillar problem and so I wrote a small script to do the job
for me. Setup the script in cron and all good to go. Remember to have
some kind of logrotate going on...the historical file, qremove_log,
does get large after awhile. Or, if you don't care about the log file,
take it out of the script. Your PATH and logpath will vary... :)
[code]
#!/bin/ksh
#
# Check for print jobs 14-days or older and remove them
#
PATH=/usr/local/bin:/opt/TWWfsw/bin:/usr/bin:/bin
logpath=/var/opt/TWWfsw/cups124/spool
alias cancel='$cupspath/cancel'
if [[ -d $logpath ]]
then
# find old jobs and save images
#
find $logpath/c* -mtime +14 -ls |tee -a /var/log/cups/qremove_log /tmp/qremove.out 2>&1 1>/dev/null
# remove old jobs
#
awk '{print $11}' /tmp/qremove.out |awk -F"/" '{print $7}'|cut -c2-10 | xargs -i cancel {} 2>&1 1>/dev/null
else
print "Error: Spool directory for CUPS does not exist.\n"
exit 1
fi
# cleanup
rm /tmp/qremove.out
# eof
[/code]
btw, the [code] and [/code] is there only to show where the script
starts and ends... :)
More information about the cups
mailing list