2

I want to create a document management system where I can get the file location of each printed document from the print job history of cups. But I can't find a way to retrieve this information.

I already tried

lpstat -W completed

but it only gives me the job id, user, timestamp etc but no information about the origin of the file. In my case the directory and the file name.

Does anyone have a hint?

1 Answer 1

2

See the cups-files.conf

RequestRoot directory

Specifies the directory that contains print jobs and other HTTP request data. The default is "/var/spool/cups".

Files are saved in a format:

/var/spool/cups/d*-nnn
/var/spool/cups/c*

where

  • * is the printer id.
  • c is the control file
  • d is the actual data
  • nnn is the document number. Starts with 001.

Oh and see if you have 'testipp' installed. It is a cups utility that will spit out everything you even need to know about the document


This gives a list of completed jobs (taken from U+L):

sudo lpstat -W completed -u $(strings /var/spool/cups/* | \
grep -A 1 job-originating-user-name | \
grep -oP '.*(?=B)' |sort -u | paste -sd ',') 
9
  • Thanks for the Answer. Very appriciated! I found in the cups-files.conf a path to another file called /var/log/syslog where the file path of printed files are logged. Unfortunately, the string of the path is limited to a certain size, which cuts a part of the path of at the end. /home/username/example/project/filename.pdf becomes /home/username/example/proje for example. I'm going to look more into this and maybe i find something better or i have to work around that. But it's definitely a start in the right direction!
    – David Sinz
    May 20, 2020 at 7:17
  • /var/log/syslog is a standard logging facility. Only use that for scanning for errors that need fixing. In case you ever go public with your document management system ... it does not need to exist and other linux will use /var/log/messages.
    – Rinzwind
    May 20, 2020 at 7:58
  • Oh i see. Ok i will look for another solution.
    – David Sinz
    May 20, 2020 at 9:15
  • How about /var/log/cups/page_log? Oh and the command I added is nifty too No directory but this assumes /var/spool/cups ;-)
    – Rinzwind
    May 20, 2020 at 9:22
  • Thanks for the terminal command :) I've tried it but it's not working yet. I looked in the /var/spool/cups folder and i'm missing the page_log file. I'm guessing my page_log output is currently written in the syslog file.
    – David Sinz
    May 20, 2020 at 9:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .