Clearing jobs which have been held too long
Michael Sweet
mike at easysw.com
Thu Mar 15 06:39:23 PDT 2007
John A. Murdie wrote:
> ...
> Is it worth me submitting my desire for a maximum hold time as an RFE?
You can, but given the reason *why* you want this I would submit an
RFE for the feature you really want, that is to automatically cancel
jobs that are held for more than 24 hours.
In the meantime, you can use the cupsGetJobs(), cupsCancelJob(), and
cupsFreeJobs() functions in the CUPS API to write a quick program to
do this; set it up as a cron job for root that runs once an hour...
#include <cups/cups.h>
#include <time.h>
int
main(int argc, char *argv[])
{
int age = 86400;
time_t firsttime = time(NULL) - age;
int num_jobs;
cups_job_t *jobs, *job;
int i;
num_jobs = cupsGetJobs(&jobs, NULL, 0, 0);
for (i = num_jobs, job = jobs; i > 0; i --, job ++)
if (job->state == IPP_JOB_HELD && job->creation_time < firsttime)
{
printf("Canceling %s-%d (%s) queued by %s...\n", job->dest,
job->id, job->title, job->user);
cupsCancelJob(job->dest, job->id);
}
cupsFreeJobs(num_jobs, jobs);
return (0);
}
--
______________________________________________________________________
Michael Sweet, Easy Software Products mike at easysw dot com
Internet Printing and Document Software http://www.easysw.com
More information about the cups
mailing list