I have a script that needs to be running in the background periodically (I've put it there with Lingon X). That script (PHP based) is 1. polling a server, 2. retrieving a PDF file from the server 3. Saving it to disk 4. Printing it using exec("lpr myFile.pdf"); 5. Playing a sound using exec("afplay ding.mp3");

When I run the script manually (php myscript.php), everything works perfectly.

However, when the script is running in the background, it does 1, 2, 3 and 5 normally, but does not print at all.

I've tried using lp instead of lpr, I've also compiled and run PDF-Printer (https://github.com/robwithhair/PDF-Printer) and still no paper is getting out of my printer. I've also tried another printer (you know...just in case). Still no luck.

I've tried to get the output from the lpr command to see if it was returning any kind of an error message, yet, nothing. There's also nothing in the printer queue.

I've also tried to run this script as root and as a regular user and still nothing makes the printer...print.

Anyone has any idea of how to accomplish this?

Here's the output of lpc status:

printer is on device 'usb' speed -1
queuing is enabled
printing is enabled
no entries
daemon present
  • Could you post the result of lpc status?
    – jherran
    Commented Nov 27, 2014 at 21:46
  • Good idea @jherran ! I've just edited the question. Commented Nov 28, 2014 at 19:43

1 Answer 1


Try to redirect the stderr so you can see what is happening.

exec("lpr myFile.pdf 2> /tmp/lpr_error");

You must log in to answer this question.

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