Lorem ipsum dolor sit amet, consectetur adipiscing elit lobortis arcu enim urna adipiscing praesent velit viverra sit semper lorem eu cursus vel hendrerit elementum morbi curabitur etiam nibh justo, lorem aliquet donec sed sit mi dignissim at ante massa mattis.
Vitae congue eu consequat ac felis placerat vestibulum lectus mauris ultrices cursus sit amet dictum sit amet justo donec enim diam porttitor lacus luctus accumsan tortor posuere praesent tristique magna sit amet purus gravida quis blandit turpis.
At risus viverra adipiscing at in tellus integer feugiat nisl pretium fusce id velit ut tortor sagittis orci a scelerisque purus semper eget at lectus urna duis convallis. porta nibh venenatis cras sed felis eget neque laoreet suspendisse interdum consectetur libero id faucibus nisl donec pretium vulputate sapien nec sagittis aliquam nunc lobortis mattis aliquam faucibus purus in.
Nisi quis eleifend quam adipiscing vitae aliquet bibendum enim facilisis gravida neque. Velit euismod in pellentesque massa placerat volutpat lacus laoreet non curabitur gravida odio aenean sed adipiscing diam donec adipiscing tristique risus. amet est placerat in egestas erat imperdiet sed euismod nisi.
“Nisi quis eleifend quam adipiscing vitae aliquet bibendum enim facilisis gravida neque velit euismod in pellentesque massa placerat”
Eget lorem dolor sed viverra ipsum nunc aliquet bibendum felis donec et odio pellentesque diam volutpat commodo sed egestas aliquam sem fringilla ut morbi tincidunt augue interdum velit euismod eu tincidunt tortor aliquam nulla facilisi aenean sed adipiscing diam donec adipiscing ut lectus arcu bibendum at varius vel pharetra nibh venenatis cras sed felis eget dolor cosnectur drolo.
When working with CUPS using remote print queues, you may find that the remote printer is not always available, has timed out, ran out of paper, has a paper jam, etc. Sometimes this causes a job to 'not-complete' and when running 'lpstat -o', you see old print jobs.We put together a quick script to auto-purge these jobs. Hopefully this helps someone in the future.Please let us know if you found this useful, or if you have any suggested changes.
#!/usr/bin/python
#
# Purge print jobs that are not-complete and older than 10 days.
#
from datetime import date, timedelta, datetime
import time
import os
howmanydaysago=10
today=date.today()
daysago=today-timedelta(days=howmanydaysago)
epoch_today=time.mktime(today.timetuple())
epoch_daysago=time.mktime(daysago.timetuple())
date_difference=epoch_today-epoch_daysago
for line in os.popen('/usr/bin/lpstat -o').readlines():
data = line.strip().split()
job=data[0].split('-')
#15 Apr 2008 12:00:00
date_time=data[4]+" "+data[5]+" "+data[6]+" 12:00:00"
pattern = '%d %b %Y %H:%M:%S'
epoch_job = int(time.mktime(time.strptime(date_time, pattern)))
difference=epoch_today - epoch_job
if difference > date_difference:
print "Canceling pending job: "+str(job[-1])
os.popen('/usr/bin/cancel '+str(job[-1]))