Operating System - HP-UX
1848177 Members
5762 Online
104022 Solutions
New Discussion

How to Move Print Jobs from One Printer to Another w/o Stopiing the Spooler?

 
SOLVED
Go to solution
Zinky
Honored Contributor

How to Move Print Jobs from One Printer to Another w/o Stopiing the Spooler?

Normally we use lpmove, but it requires the spooler/printing system to be down and restarted -- resulting in reprinting of currently printing jobs.

Our current workaround is this:

reject srcprntr
disable srcprntr
cd /var/spool/lp/request/srcprntr
for file in d*;do
lp -ddstprntr $file
done
cancel -e srcprntr
enable srcprintr
accpt srcprntr


Any other tip/trick to do this? Does CUPS improve on this SYSV printing weakness?

Hakuna Matata

Favourite Toy:
AMD Athlon II X6 1090T 6-core, 16GB RAM, 12TB ZFS RAIDZ-2 Storage. Linux Centos 5.6 running KVM Hypervisor. Virtual Machines: Ubuntu, Mint, Solaris 10, Windows 7 Professional, Windows XP Pro, Windows Server 2008R2, DOS 6.22, OpenFiler
8 REPLIES 8
Geoff Wild
Honored Contributor

Re: How to Move Print Jobs from One Printer to Another w/o Stopiing the Spooler?

Nelson,

As far as "On the destination printer though the printjobs are listed with no indication of what jobs/files they are." - I can't see a way around this - as whenever you issue a lp -d, it will autmatically create a new job name...

That is, say the original job was:

RF22-1129

And you issue a:

cd /var/spool/lp/request/RF22
lp -dW052 dA1129pc0003

It will create a new request id - in my attempt this was:

request id is W052-1452


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Zinky
Honored Contributor

Re: How to Move Print Jobs from One Printer to Another w/o Stopiing the Spooler?

There is actually a way, you parse the c* file but I think that is a minor issue.
Hakuna Matata

Favourite Toy:
AMD Athlon II X6 1090T 6-core, 16GB RAM, 12TB ZFS RAIDZ-2 Storage. Linux Centos 5.6 running KVM Hypervisor. Virtual Machines: Ubuntu, Mint, Solaris 10, Windows 7 Professional, Windows XP Pro, Windows Server 2008R2, DOS 6.22, OpenFiler
Geoff Wild
Honored Contributor
Solution

Re: How to Move Print Jobs from One Printer to Another w/o Stopiing the Spooler?

Just a little enhacment to your script - hope you don't mind.

#!/bin/sh
# script to move jobs without shutting down the spooler
#
if [ $# -lt 2 -o \( $# -gt 2 -a $# -lt 4 \) ]
then
echo "Usage:"
echo "lpmove.sh \"source queue\" \"destination queue\""
echo "Example:"
echo "lpmove.sh RF22 W052"
exit 1
fi
echo " "


disable $1 -r"moving print jobs to print queue $2"

cd /var/spool/lp/request/$1
for file in d*;do
lp -d$2 $file
done
cancel -e $1
enable $1


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Procnus
Frequent Advisor

Re: How to Move Print Jobs from One Printer to Another w/o Stopiing the Spooler?

I normally use lpalt in the following way:
-- Insert script --
#!/usr/bin/ksh

if [ $# -lt 1 ]; then
echo "Usage : $0 []"
echo " Default = konica65"
exit 1
fi

file_list=$(lpstat $1 | grep $1 | cut -f1 -d\ )
dest=${2:-"konica65"}

for i in $file_list; do
lpalt -d$dest $i
echo "File $i sent to $dest"
done

-- end insert --
The requirement is that you are either the owner of the print jobs or root. This will move every print job on the from_queue to the to_queue.

For a single print job use the lpalt command by itself:
lpalt -dprn2 prn1-1234

Where prn1-1234 is the print job on printer prn1 and prn2 is where you want it to print.

Cheers
Steven
Zinky
Honored Contributor

Re: How to Move Print Jobs from One Printer to Another w/o Stopiing the Spooler?

Thanks Steven!

So there is indeed an "lpalt" command that do move print jobs from one queue to another.


Kool...!
Hakuna Matata

Favourite Toy:
AMD Athlon II X6 1090T 6-core, 16GB RAM, 12TB ZFS RAIDZ-2 Storage. Linux Centos 5.6 running KVM Hypervisor. Virtual Machines: Ubuntu, Mint, Solaris 10, Windows 7 Professional, Windows XP Pro, Windows Server 2008R2, DOS 6.22, OpenFiler
Geoff Wild
Honored Contributor

Re: How to Move Print Jobs from One Printer to Another w/o Stopiing the Spooler?

Very nice - and lpalt doesn't stop/start the spooler...

I modified Steven's script to us AWK instead:

#!/bin/sh
# script to move jobs without shutting down the spooler
if [ $# -lt 2 -o \( $# -gt 2 -a $# -lt 4 \) ]
then
echo "Usage:"
echo "lpmove.sh \"source queue\" \"destination queue\""
echo "Example:"
echo "lpmove.sh RF22 W052"
exit 1
fi
echo " "

src=$1
DEST=$2

for JOB in `lpstat $SRC | grep $SRC | awk '{print $1}'`
do
lpalt -d$DEST $JOB
echo "File $JOB sent to $DEST"
done



Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Stuart Powell
Super Advisor

Re: How to Move Print Jobs from One Printer to Another w/o Stopiing the Spooler?

Nelson,

I don't know if you're still interested; we add the following script to root's crontab:

for i in `lpstat -o |grep #1printername-|awk '{print $1}'`
do
if [ ${i} = "" ]
then
exit
else
lpalt $i -d#2printername
fi
done

We disable #1printername and then set this script with all *'s in the time parameters. So everyminute the jobs on #1printername are redirected to #2printername. We have found it to be an easy band-aid for when a printer is down for maintenance.

Stuart
Sometimes the best answer is another question
Zinky
Honored Contributor

Re: How to Move Print Jobs from One Printer to Another w/o Stopiing the Spooler?

Thanks Stewart..

Our enterprise is quite heavy on UNIX printing. Before we use to print through Windows but that has been problem plagued. We often lose connectivity and printers need to be redefined or re-established.

We are developing procedures and roles and movement of print jobs from one printer to was always done via lpmove or the workaround we developed... NOw that there indeed is "lpalt" .. we'll certainly use this..
Hakuna Matata

Favourite Toy:
AMD Athlon II X6 1090T 6-core, 16GB RAM, 12TB ZFS RAIDZ-2 Storage. Linux Centos 5.6 running KVM Hypervisor. Virtual Machines: Ubuntu, Mint, Solaris 10, Windows 7 Professional, Windows XP Pro, Windows Server 2008R2, DOS 6.22, OpenFiler