- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- old print job removal
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2006 04:03 AM
12-04-2006 04:03 AM
old print job removal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2006 04:22 AM
12-04-2006 04:22 AM
Re: old print job removal
jobline=`lpstat -o | grep priority`
jobid=`echo $jobline|awk {'print $1'}
day=`echo $jobline|awk {'print $6'}
month=`echo $jobline|awk {'print $5'}
jobtime=`echo $jobline|awk {'print $7'}
usning these variables and using the caljd.sh script, provided by Clay Stephenson (go to http://mirrors.develooper.com/hpux/ and look for words "Date Hammer" to get either shell or perl versions), you can calculate the time past since the request has been submitted and make a decision to delete it or not.
Hope this helps.
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2006 05:04 AM
12-04-2006 05:04 AM
Re: old print job removal
# cat /usr/local/bin/lpqpurge
#!/bin/sh
#
# script to cancel jobs older then the current month
# run say on the 21st of each month
# gwild
# get the current month
M=`date +%b`
# cancel any jobs older then current month
# lpstat -o returns the following fields
# GB01-7606 ipradm priority 3 Apr 22 04:05 on GB01
# so, compare field 5 to the current month
for JOB in `lpstat -o |grep -v bytes|awk '$5ne"$M"{print $1}'`
do
cancel $JOB
done
# could have been done on 1 line like so:
# lpstat -o |grep -v bytes|awk '$5ne"`date +%b`"{print $1}'|xargs cancel
# but if there are no jobs older then current month - then cancel outputs error
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2006 05:04 AM
12-04-2006 05:04 AM
Re: old print job removal
# cat /usr/local/bin/lpqpurge
#!/bin/sh
#
# script to cancel jobs older then the current month
# run say on the 21st of each month
# gwild
# get the current month
M=`date +%b`
# cancel any jobs older then current month
# lpstat -o returns the following fields
# GB01-7606 ipradm priority 3 Apr 22 04:05 on GB01
# so, compare field 5 to the current month
for JOB in `lpstat -o |grep -v bytes|awk '$5ne"$M"{print $1}'`
do
cancel $JOB
done
# could have been done on 1 line like so:
# lpstat -o |grep -v bytes|awk '$5ne"`date +%b`"{print $1}'|xargs cancel
# but if there are no jobs older then current month - then cancel outputs error
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2006 05:09 AM
12-04-2006 05:09 AM
Re: old print job removal
Firstly, you need to 'cancel' those jobs that you find are candidates. In this way, you keep the lp subsystem "happy".
This Perl script lists the jobs that exist:
#/usr/bin/perl
use strict;
use warnings;
my @requests;
my $request;
@requests=grep{/priority/} `lpstat`;
for $request (@requests) {
print $request;
}
From here, you can enhance the script to snip the request-ID and, using the Perl 'Date::Calc' module's 'Delta_Days' function, calculate the age in days of the request. If it meets your criteria, make a 'cancel' request by calling 'system()'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2006 06:35 AM
12-04-2006 06:35 AM
Re: old print job removal
Here's a complete working Perl script.
# cat .purgelp
#!/usr/bin/perl
use strict;
use warnings;
use Date::Calc qw( Decode_Month Delta_Days );
my $days_to_remove = @ARGV ? $ARGV[0] : 5;
my @requests;
my @fields;
my ( $line, $month, $age );
my ( $currday, $currmon, $curryr ) = (localtime)[ 3, 4, 5 ];
$currmon++;
$curryr += 1900;
@requests = grep {/priority/} `/usr/bin/lpstat`;
for $line (@requests) {
print $line;
@fields = split /\s+/, $line;
$month = Decode_Month( $fields[4] );
$age = Delta_Days( $curryr, $currmon, $currday, $curryr, $month,
$fields[5] );
if ( $age >= $days_to_remove ) {
system("/usr/bin/cancel $fields[0]");
}
}
1;
...run it passing the number of days at which you want to cancel the print job. By default, without specification, the script assumes 5-days. For example:
# ./purgelp 0
remotep-558 root priority 0 Dec 4 14:30
request "remotep-558" cancelled
remotep-559 root priority 0 Dec 4 14:30
request "remotep-559" cancelled
remotep-560 root priority 0 Dec 4 14:30
request "remotep-560" cancelled
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2006 02:04 AM
12-05-2006 02:04 AM
Re: old print job removal
CPAN.pm: Going to build S/ST/STBEY/Bit-Vector-6.4.tar.gz
Checking if your kit is complete...
Looks good
Writing Makefile for Bit::Vector
Writing patchlevel.h for /opt/perl_32/bin/perl (5.008007)
cp lib/Bit/Vector/Overload.pm blib/lib/Bit/Vector/Overload.pm
cp Vector.pm blib/lib/Bit/Vector.pm
cp Vector.pod blib/lib/Bit/Vector.pod
cp lib/Bit/Vector/String.pod blib/lib/Bit/Vector/String.pod
cp lib/Bit/Vector/Overload.pod blib/lib/Bit/Vector/Overload.pod
cp lib/Bit/Vector/String.pm blib/lib/Bit/Vector/String.pm
cc -c -D_POSIX_C_SOURCE=199506L -D_REENTRANT -Ae -D_HPUX_SOURCE -Wl,+vnocompatwarnings +Z -DUSE_SITECUSTOMIZE -DNO_HASH_SEED -D_LARGEFILE_SOURCE -D_FI
LE_OFFSET_BITS=64 -fast +Onolimit +Opromote_indirect_calls +DAportable +DS2.0 -DVERSION=\"6.4\" -DXS_VERSION=\"6.4\" +Z "-I/opt/perl_32/lib/5.8.7/PA-RISC1.1-
thread-multi/CORE" BitVector.c
(Bundled) cc: warning 480: The -A option is available only with the C/ANSI C product; ignored.
(Bundled) cc: warning 480: The +Z option is available only with the C/ANSI C product; ignored.
(Bundled) cc: warning 422: Unknown option "f" ignored.
(Bundled) cc: warning 480: The +Onolimit option is available only with the C/ANSI C product; ignored.
(Bundled) cc: warning 480: The +Opromote_indirect_calls option is available only with the C/ANSI C product; ignored.
(Bundled) cc: warning 480: The +Z option is available only with the C/ANSI C product; ignored.
(Bundled) cc: "ToolBox.h", line 40: warning 5: "signed" will become a keyword.
(Bundled) cc: "ToolBox.h", line 40: error 1000: Unexpected symbol: "char".
(Bundled) cc: "ToolBox.h", line 41: warning 5: "signed" will become a keyword.
(Bundled) cc: "ToolBox.h", line 41: error 1000: Unexpected symbol: "char".
(Bundled) cc: "ToolBox.h", line 42: warning 5: "signed" will become a keyword.
(Bundled) cc: "ToolBox.h", line 41: warning 525: Redeclaration of identifier "signed".
(Bundled) cc: "ToolBox.h", line 42: error 1000: Unexpected symbol: "short".
(Bundled) cc: "ToolBox.h", line 43: warning 5: "signed" will become a keyword.
(Bundled) cc: "ToolBox.h", line 43: error 1000: Unexpected symbol: "short".
(Bundled) cc: "ToolBox.h", line 44: warning 5: "signed" will become a keyword.
(Bundled) cc: "ToolBox.h", line 44: error 1000: Unexpected symbol: "int".
(Bundled) cc: "ToolBox.h", line 45: warning 5: "signed" will become a keyword.
(Bundled) cc: "ToolBox.h", line 45: error 1000: Unexpected symbol: "int".
(Bundled) cc: "ToolBox.h", line 46: warning 5: "signed" will become a keyword.
(Bundled) cc: "ToolBox.h", line 46: error 1000: Unexpected symbol: "long".
(Bundled) cc: "ToolBox.h", line 47: warning 5: "signed" will become a keyword.
(Bundled) cc: "ToolBox.h", line 47: error 1000: Unexpected symbol: "long".
(Bundled) cc: "ToolBox.h", line 71: error 1000: Unexpected symbol: "*".
(Bundled) cc: error 2017: Cannot recover from earlier errors, terminating.
*** Error exit code 1
Stop.
/usr/bin/make -- NOT OK
Running make test
Can't test without successful make
Running make install
make had returned bad status, install seems impossible
Running make for S/ST/STBEY/Date-Calc-5.4.tar.gz
Is already unwrapped into directory /.cpan/build/Date-Calc-5.4
CPAN.pm: Going to build S/ST/STBEY/Date-Calc-5.4.tar.gz
cp lib/Date/Calc/Object.pod blib/lib/Date/Calc/Object.pod
cp lib/Date/Calendar/Year.pm blib/lib/Date/Calendar/Year.pm
cp Calc.pod blib/lib/Date/Calc.pod
cp lib/Date/Calendar/Profiles.pm blib/lib/Date/Calendar/Profiles.pm
cp lib/Date/Calc/Object.pm blib/lib/Date/Calc/Object.pm
cp Calendar.pod blib/lib/Date/Calendar.pod
cp lib/Date/Calendar/Year.pod blib/lib/Date/Calendar/Year.pod
cp lib/Date/Calendar/Profiles.pod blib/lib/Date/Calendar/Profiles.pod
cp Calendar.pm blib/lib/Date/Calendar.pm
cp Calc.pm blib/lib/Date/Calc.pm
/opt/perl_32/bin/perl /opt/perl_32/lib/5.8.7/ExtUtils/xsubpp -typemap /opt/perl_32/lib/5.8.7/ExtUtils/typemap -typemap typemap Calc.xs > Calc.xsc && mv
Calc.xsc Calc.c
cc -c -D_POSIX_C_SOURCE=199506L -D_REENTRANT -Ae -D_HPUX_SOURCE -Wl,+vnocompatwarnings +Z -DUSE_SITECUSTOMIZE -DNO_HASH_SEED -D_LARGEFILE_SOURCE -D_FI
LE_OFFSET_BITS=64 -fast +Onolimit +Opromote_indirect_calls +DAportable +DS2.0 -DVERSION=\"5.4\" -DXS_VERSION=\"5.4\" +Z "-I/opt/perl_32/lib/5.8.7/PA-RISC1.1-
thread-multi/CORE" Calc.c
(Bundled) cc: warning 480: The -A option is available only with the C/ANSI C product; ignored.
(Bundled) cc: warning 480: The +Z option is available only with the C/ANSI C product; ignored.
(Bundled) cc: warning 422: Unknown option "f" ignored.
(Bundled) cc: warning 480: The +Onolimit option is available only with the C/ANSI C product; ignored.
(Bundled) cc: warning 480: The +Opromote_indirect_calls option is available only with the C/ANSI C product; ignored.
(Bundled) cc: warning 480: The +Z option is available only with the C/ANSI C product; ignored.
cpp: "/opt/perl_32/lib/5.8.7/PA-RISC1.1-thread-multi/CORE/perlio.h", line 108: error 4065: Recursion in macro "PerlIO".
*** Error exit code 1
Stop.
/usr/bin/make -- NOT OK
Running make test
Can't test without successful make
Running make install
make had returned bad status, install seems impossible
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2006 02:15 AM
12-05-2006 02:15 AM
Re: old print job removal
Perl is a great tool - but for simple things - why use all that overhead?
My sh script is only 5 lines of code (could be one) and much more efficient (doesn't have to make extra library calss, etc).
Just my 2 cents.
Obivously, no points for this post.
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2006 02:26 AM
12-05-2006 02:26 AM
Re: old print job removal
It appears that your version of Perl was built using HP's compiler. If you do:
# perl -V
...and look under the section headed "Compiler" you should see that.
You can fetch and install a 'gcc' compiled Perl in the event that you don't have an HP ANSI C compiler available:
http://mirrors.develooper.com/hpux/
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2006 12:14 PM
12-07-2006 12:14 PM
Re: old print job removal
It was working for me many yrs when we spooled on HP-UX, nowadays we use cheap SuSe lnx with cups as spool servers.
Simplifies also administration for non-unix personell which do this via browser...
It's quite expensive to use HP-UX processing for printout.
I used to run the CancelOldPrint script in cron. It ran from one central server and removed print more than 8 days old.
The monthdays, yeardays and ymd2yd is some old hints I picked up some place... It helps calculating age and might be useful for other purpose as well.
/Tor-Arne