Clearing jobs which have been held too long

John A. Murdie john at cs.york.ac.uk
Thu Mar 15 06:54:24 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

Mike, I'm impressed with your speed at coding of the basis for a solution to my problem! Thank you! I think that I can probably even add code to E-mail the user who failed to cancel the held job in that time, to tell them that the job has been cancelled automatically.

I still think, however, that some (most?) system administrators are not going to be happy with users who leave jobs in the held state indefinitely. The reason is one simply of the untidyness of loose ends -
held jobs build up, and I have to cancel them by hand and E-mail the user manually to say that I've done this. I'd like an automatic solution.

I'll submit an RFE asking for an integrated automatic feature of CUPS to cause held jobs to be deleted after a configured time. Administrators who are happy for users jobs to remain held indefinitely can set the timeout to 'indefinite'. If this feature is not do-able, or you think it unwise, well, you can always say "Sorry, no."

Thank you once again for your suggested solution!

John A. Murdie






More information about the cups mailing list