- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- cleaning print jobs that was older than 3 days
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
Discussions
Discussions
Discussions
Forums
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
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
тАО06-08-2005 09:09 AM
тАО06-08-2005 09:09 AM
i wouuld like to write a script that will clean out print jobs those are older that 3 day.
first i though the location
/var/spool/lp/request is the right place to work on, but the hp support advise that the cancel command was the only reliable way to remove print jobs from the queue while keeping the data file current.
lpstat -u |awk '{print$1}'|xargs -cancel
but then the print $1 will return the job # hp5000-1562 and J7009_stdlst. how do i get rid of this J7009_stdlst and add in the date so it only show me print jobs older than 3 day.
Thanks in advance.
Tom
hp5000-1562
J7009_stdlst
hp5000-1563
J7010_stdlst
hp5000-1564
J7008_stdlst
hp5000-1565
J7007_stdlst
hp5000-1532 batch priority 1 Jun 8 00:54
J7014_stdlst 6497 bytes
hp5000-1553 albany priority 0 Jun 8 01:16
ivanhoe1.txt 62 bytes
hp5000-1555 batch priority 1 Jun 8 02:12
J7011_stdlst 5073 bytes
hp5000-1556 batch priority 1 Jun 8 02:12
J7015_stdlst 4617 bytes
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 09:30 AM
тАО06-08-2005 09:30 AM
SolutionAnyway, here's a way to get it done which does use the script method to generate a file that has the cancel command in it. So, everyone is happy. Run this from cron once a day. Test this on a test system first right, OK? That's because this is really a script I use to see if any jobs are older than three days that I just changed on the fly for you to become a program to run cancel commands. It's not tested (I'm leaving that to you) but it should be fine - but you need to test it on a test server with junk stuff in the queue. Just change the "+2" value in the find command to "0" to make it delete stuff in queues from today on your test server - if you don't want to wait three days to test the code.
#!/bin/ksh
export mytmpfile=/var/tmp/old_print_jobs.$$
cd /var/spool/lp/request|| exit 22
for i in `find . -type f -name "cA*${HNAME}" -mtime +2`
do
printer=`echo $i | cut -f 2 -d"/"`
job=`echo $i | cut -f 3 -d"/"| sed -e "s/^cA//" -e "s/$HNAME//"`
echo /usr/bin/cancel -e ${printer}-${job}
done > $mytmpfile
typeset -i PRINT_JOB_CT
PRINT_JOB_CT=`cat ${mytmpfile}|wc -l`
if [[ $PRINT_JOB_CT -gt 0 ]]; then
. $mytmpfile
fi
rm $mytmpfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 09:59 AM
тАО06-08-2005 09:59 AM
Re: cleaning print jobs that was older than 3 days
Attached perl script can do the job for you. Will list those jobs. Some minor mods and you can have it delete the jobs as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 10:02 AM
тАО06-08-2005 10:02 AM
Re: cleaning print jobs that was older than 3 days
Again, this is set to list the files. You can modify to delete as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 10:35 AM
тАО06-08-2005 10:35 AM
Re: cleaning print jobs that was older than 3 days
i will test it.
Regards,
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 11:06 AM
тАО06-08-2005 11:06 AM
Re: cleaning print jobs that was older than 3 days
You can actually parse the output of lpstat -o using awk (or Perl) and then calculate the age of the job. You actually need two utilities so I have to do two attachments. 1) canceloldprjobs.sh 2) caljd.sh
There is a possibility that the job could appear to be newer than today. Consider lpstat returing Dec 31 and today is Jan 4. Because lpstat does not include the year, I first do the calculation and if the age is negative, I repeat using the previous year.
I've been using this script as a cron job for a long time.
Here's canceloldprjobs.sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 11:08 AM
тАО06-08-2005 11:08 AM
Re: cleaning print jobs that was older than 3 days
I suggest that you install caljd.sh in /usr/local/bin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 11:11 AM
тАО06-08-2005 11:11 AM
Re: cleaning print jobs that was older than 3 days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 02:45 PM
тАО06-08-2005 02:45 PM
Re: cleaning print jobs that was older than 3 days
your scripts work beautifully. one question for you, if it is possible to use these scripts to cancel job of individual user.
ex: when i run the script manuall, it will prompt me for a user name and after insert the username it will clean out all spool files of that user.
Hi Rick,
when i ran your script, it sent back an email with a list of spoolfiles (cool)
but it did not delete the spoolfiles, I did modify (3 * 3600) to (1 * 1800) i think i did not do it right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 03:08 PM
тАО06-08-2005 03:08 PM
Re: cleaning print jobs that was older than 3 days
add grep in the line
lpstat -u |grep hp5000 |awk '{print$1}'|xargs -cancel
or alternatively you can use
lpstat -u |grep hp5000 |cut -c 8-12 |xargs -cancel
in your script
Cheers!!!
eknath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 05:32 PM
тАО06-08-2005 05:32 PM
Re: cleaning print jobs that was older than 3 days
modified yours abit and that is what i want.
Thanks,
tom
#!/usr/bin/sh
echo 'Enter user name\n'
read USER
lpstat -u |grep $USER |awk '{print $1}'|xargs cancel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2005 02:21 AM
тАО06-09-2005 02:21 AM
Re: cleaning print jobs that was older than 3 days
By adding in the rm commands you can have it list those files, send an email, and then delete.
You know what is deleted in this manner.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2005 02:44 AM
тАО06-09-2005 02:44 AM
Re: cleaning print jobs that was older than 3 days
Regards,
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2005 02:44 AM
тАО06-09-2005 02:44 AM