- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- scripting
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
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
09-02-2005 01:56 AM
09-02-2005 01:56 AM
scripting
apmsrep-5492 dklerkc priority 0 May 18 11:41
apmsrep-7963 dklerkc priority 0 May 18 12:26
phbclab-2715 potasr priority 0 May 23 15:05
pharec-692 potasr priority 0 Jun 24 10:39
pharec-693 potasr priority 0 May 25 09:23
rbstat2-6414 henriqt priority 0 May 25 11:04
phbclab-1613 potasr priority 0 May 27 07:42
phbclab-7175 potasr priority 0 May 27 12:47
rbphlab-160 dtoitf1 priority 0 Jun 24 11:17
rbphlab-206 dtoitf1 priority 0 May 30 09:32
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2005 02:04 AM
09-02-2005 02:04 AM
Re: scripting
# 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
09-02-2005 02:06 AM
09-02-2005 02:06 AM
Re: scripting
Though its not very clear to me , what exactly are you looking for , can you please explain little bit.
As from the output its showing the dates all are older than 24hrs.
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2005 02:10 AM
09-02-2005 02:10 AM
Re: scripting
You can just run find command to know what is older as defined by you.
find /var/spool/lp/request -type f -mtime +2
Will list files older than 2 days. Then you can combine this into a script to delete such print reqests.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2005 02:12 AM
09-02-2005 02:12 AM
Re: scripting
find /target -type f -mtime +1 -exec rm {} \;
See man find.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2005 02:22 AM
09-02-2005 02:22 AM
Re: scripting
You can get the current date with many format , and need to compare with date in the lpstat -o output , and the job can be done.
$ date +%d%m will give in numeric format.
i.e 0209
$ date +%b%d
Sep02
$ date | awk '{print $2 $3}'
Sep2
Also the find command can be useful inside the script,
Cheers,
Raj.