Skip to content

Instantly share code, notes, and snippets.

@mklooss
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mklooss/7a79db2d67821e8642e0 to your computer and use it in GitHub Desktop.
Save mklooss/7a79db2d67821e8642e0 to your computer and use it in GitHub Desktop.
automatic print pdf
*/1 * * * * root find /printer -iname "*.pdf" -exec printpdf "{}" \; > /dev/null
#!/bin/bash
DATE=`date`
PRINTER=Brother_DCP-9055CDN
# check if file already printed and try to remove this file
if [ -f "/tmp/printed.tmp" ]; then
while read p; do
if [ "$p" = "$1" ]; then
rm -f "$1"
echo "'$1' already printed"
exit
fi
done </tmp/printed.tmp
fi
echo "$DATE print file $1" >> /var/log/printpdf.log
lp -d $PRINTER "$1" >> /var/log/printpdf.log
echo "$DATE remove $1" >> /var/log/printpdf.log
echo $1 >> /tmp/printed.tmp
rm -f "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment