print using command line linux

To list avaiable printers

lpstat -p

To print a plain text in one printer

echo 'oi' | lp -d printerNameHere

To print a pdf file in one printer

lp -d printerNameHere file.pdf

To print to parallel printer

echo 'oi' > /dev/lp0

To view printer log

tail -f /var/log/cups/page_log

if you print to a pdf printer the files will be saved in: /var/spool/cups-pdf

Advertisements

execute script before/after logrotate execution

to execute command/script before or after logrotate for apache logs use the entryes: prerotate or postrotate

vi /etc/logrotate.d/httpd

/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    delaycompress
    prerotate
        /bin/echo 'execute before restart' || true
    endscript
    postrotate
        /bin/kill -HUP `cat /var/run/httpd/httpd.pid 2>/dev/null` 2> /dev/null || true
        /bin/echo 'execute after restart' || true 
    endscript
}

to force execution of this logrotate file:

logrotate -f /etc/logrotate.d/httpd