Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm running Fedora 17, Gnome (3?), and using bash from terminal. Whenever I run lpstat I only get a list of my jobs, but every time I go to retrieve my jobs from the printer, somebody else is printing and mine hasn't even started! What gives?

I want to view a list of all users' jobs, not just mine.

I tried lpq to no avail. I've also tried lpstat -t and same result -- just my jobs, not anyone else's. What am I doing wrong here?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

lpstat -u all (as root) should show all users and all jobs that are currently queued:

-u <logon-IDs>

Prints the status of output requests for users, in which can be one or all of the following:

  • <user> - A user on the local system, as in lpstat -u user
  • <host!user> - A user on a system, as in lpstat -u systema!user
  • <host!all> - All users on a particular system, as in lpstat- u systema!all
  • <all!user> - A particular user on all systems, as in lpstat -u all!user
  • all - All users on all systems specified, as in lpstat -u all
share|improve this answer
    
Sorry for the late reply - I've been in the hospital for a while. @charlesbridge - Thanks for your response -- I believe that is the solution I was looking for! Unfortunately, I am not longer working at that contract and am unable to test it. –  CodeSlayer2010 Apr 21 '13 at 20:46
    
I'm trying this while logged into the actual CUPS server and it doesn't seem to work. I'm trying lpstat -u all and get nothing. But if I grep through the /var/spool/cups/* directory for usernames I'm finding them. –  slm Oct 8 at 1:47
    
The command only shows currently queued jobs, not the history of jobs. I've updated the answer to clarify that. –  charlesbridge Oct 8 at 13:40

The accepted answer did not work for me but the following method did. However, if you have a directory that contains your LPD control files, typically it's /var/spool/cups, you'll notice a bunch of control files in there. These files are kept as a result of theMaxJobs` setting, which defaults to 500 when unset.

$ sudo ls -l /var/spool/cups/ | wc -l
502

Another source of usernames?

If you look through these files you'll notice that they contain usernames, and not just ones for accounts that are present on the system.

$ strings /var/spool/cups/* | grep -A 1 job-originating-user-name | head -5
job-originating-user-name
tammyB
--
job-originating-user-name
tammyB

So we could select all the entries that contain the username followed by the B.

$ sudo strings /var/spool/cups/* | grep -A 1 job-originating-user-name | \
    grep -oP '.*(?=B)' | sort -u
ethan
guest-AO22e7
root
sam
saml
slm
tammy

This list can then be adapted in the same way as we were originally using to take the list of users from getent passwd, like so:

$ sudo lpstat -W completed -u $(strings /var/spool/cups/* | \
    grep -A 1 job-originating-user-name | \
    grep -oP '.*(?=B)' |sort -u | paste -sd ',') 
mfc-8480dn-1525         tammy           545792   Thu 28 Nov 2013 01:36:59 PM EST
mfc-8480dn-1526         saml            699392   Sat 30 Nov 2013 10:34:34 AM EST
mfc-8480dn-1652         root              1024   Tue 28 Jan 2014 01:19:34 AM EST
mfc-8480dn-1672         saml              1024   Sun 09 Feb 2014 01:56:26 PM EST

References

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.