delete old print jobs
Kurt Pfeifle
kurt.pfeifle at infotec.com
Fri May 18 12:56:02 PDT 2007
Amy wrote:
> Thank you for this suggestion. I don't think restarting cups is a good
> option in our situation. I'd rather do it with the cancel command.
> Something like this:
>
> lpstat -o |grep -v "10 May"|while read id junk; do sudo cancel $id; done
>
> ....works for deleting any job not on May 10 but I'm looking for
> something to delete jobs older than 5 days.
>
>
> Any other ideas?
you could replace the 'grep -v "10 May"' part with this:
egrep -v '(10 May|11 May|12 May|13 May|14 May)'
(which matches all dates not listed in the expression). But I assume you are still not yet content: you don't want to manually insert the dates either...
I'm afraid, I can't right now re-call or find some old link to a cool article which showed how to use some commandline params to tell "date" to show the date of N days ago. However, maybe this Perl one-liner can help you get started with creating a date expression as you require it:
perl -e 'use Date::Calc qw(Today Add_Delta_Days);my ($y, $m, $d) = Add_Delta_Days(Today(), -5);print "$d $m $y\n";'
(This uses the Perl module Date::Calc; you can probably easily find a way to convert the numerical month into the three letter abbreviation.)
More information about the cups
mailing list