<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: scripting in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3617752#M235322</link>
    <description>Hers a script I use - to help you get started:&lt;BR /&gt;&lt;BR /&gt;# cat /usr/local/bin/lpqpurge&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;#&lt;BR /&gt;# script to cancel jobs older then the current month&lt;BR /&gt;# run say on the 21st of each month&lt;BR /&gt;# gwild&lt;BR /&gt;&lt;BR /&gt;# get the current month&lt;BR /&gt;&lt;BR /&gt;M=`date +%b`&lt;BR /&gt;&lt;BR /&gt;# cancel any jobs older then current month&lt;BR /&gt;# lpstat -o returns the following fields&lt;BR /&gt;# GB01-7606           ipradm         priority 3  Apr 22 04:05 on GB01&lt;BR /&gt;# so, compare field 5 to the current month&lt;BR /&gt;&lt;BR /&gt;for JOB in `lpstat -o  |grep -v bytes|awk '$5ne"$M"{print $1}'`&lt;BR /&gt;do&lt;BR /&gt;    cancel $JOB&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;# could have been done on 1 line like so:&lt;BR /&gt;# lpstat -o |grep -v bytes|awk '$5ne"`date +%b`"{print $1}'|xargs cancel&lt;BR /&gt;# but if there are no jobs older then current month - then cancel outputs error&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
    <pubDate>Fri, 02 Sep 2005 09:04:07 GMT</pubDate>
    <dc:creator>Geoff Wild</dc:creator>
    <dc:date>2005-09-02T09:04:07Z</dc:date>
    <item>
      <title>scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3617751#M235321</link>
      <description>I am battling to compare dates in a script. This is the output of lpstat -o.  I want to delete anything thats older then 24hrs. How do I compare this date with sysdate.&lt;BR /&gt;&lt;BR /&gt;apmsrep-5492        dklerkc        priority 0  May 18 11:41 &lt;BR /&gt;apmsrep-7963        dklerkc        priority 0  May 18 12:26 &lt;BR /&gt;phbclab-2715        potasr         priority 0  May 23 15:05 &lt;BR /&gt;pharec-692          potasr         priority 0  Jun 24 10:39 &lt;BR /&gt;pharec-693          potasr         priority 0  May 25 09:23 &lt;BR /&gt;rbstat2-6414        henriqt        priority 0  May 25 11:04 &lt;BR /&gt;phbclab-1613        potasr         priority 0  May 27 07:42 &lt;BR /&gt;phbclab-7175        potasr         priority 0  May 27 12:47 &lt;BR /&gt;rbphlab-160         dtoitf1        priority 0  Jun 24 11:17 &lt;BR /&gt;rbphlab-206         dtoitf1        priority 0  May 30 09:32 &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Sep 2005 08:56:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3617751#M235321</guid>
      <dc:creator>Raj Mithal_1</dc:creator>
      <dc:date>2005-09-02T08:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3617752#M235322</link>
      <description>Hers a script I use - to help you get started:&lt;BR /&gt;&lt;BR /&gt;# cat /usr/local/bin/lpqpurge&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;#&lt;BR /&gt;# script to cancel jobs older then the current month&lt;BR /&gt;# run say on the 21st of each month&lt;BR /&gt;# gwild&lt;BR /&gt;&lt;BR /&gt;# get the current month&lt;BR /&gt;&lt;BR /&gt;M=`date +%b`&lt;BR /&gt;&lt;BR /&gt;# cancel any jobs older then current month&lt;BR /&gt;# lpstat -o returns the following fields&lt;BR /&gt;# GB01-7606           ipradm         priority 3  Apr 22 04:05 on GB01&lt;BR /&gt;# so, compare field 5 to the current month&lt;BR /&gt;&lt;BR /&gt;for JOB in `lpstat -o  |grep -v bytes|awk '$5ne"$M"{print $1}'`&lt;BR /&gt;do&lt;BR /&gt;    cancel $JOB&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;# could have been done on 1 line like so:&lt;BR /&gt;# lpstat -o |grep -v bytes|awk '$5ne"`date +%b`"{print $1}'|xargs cancel&lt;BR /&gt;# but if there are no jobs older then current month - then cancel outputs error&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Fri, 02 Sep 2005 09:04:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3617752#M235322</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2005-09-02T09:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3617753#M235323</link>
      <description>Hi Raj Mithal ,&lt;BR /&gt;&lt;BR /&gt;Though its not very clear to me , what exactly are you looking for , can you please explain little bit.&lt;BR /&gt;&lt;BR /&gt;As from the output its showing the dates all are older than 24hrs. &lt;BR /&gt;&lt;BR /&gt;Raj.&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Sep 2005 09:06:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3617753#M235323</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2005-09-02T09:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3617754#M235324</link>
      <description>You can do some scripting as advised. The way I approach is as follows. Any print request , it goes to /var/spool/lp/request directory.&lt;BR /&gt;&lt;BR /&gt;You can just run find command to know what is older as defined by you.&lt;BR /&gt;&lt;BR /&gt;find /var/spool/lp/request -type f -mtime +2 &lt;BR /&gt;Will list files older than 2 days. Then you can combine this into a script to delete such print reqests.</description>
      <pubDate>Fri, 02 Sep 2005 09:10:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3617754#M235324</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-09-02T09:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3617755#M235325</link>
      <description>Or you can let the find command do the removal for you:&lt;BR /&gt;&lt;BR /&gt;find /target -type f -mtime +1 -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;See man find.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Fri, 02 Sep 2005 09:12:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3617755#M235325</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2005-09-02T09:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3617756#M235326</link>
      <description>Hi Raj ,&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;$ date +%d%m  will give in numeric format.&lt;BR /&gt;i.e  0209&lt;BR /&gt;$ date +%b%d&lt;BR /&gt;Sep02&lt;BR /&gt;&lt;BR /&gt;$ date | awk '{print $2 $3}'&lt;BR /&gt;Sep2&lt;BR /&gt;&lt;BR /&gt;Also the find command can be useful inside the script,&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Raj.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Sep 2005 09:22:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3617756#M235326</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2005-09-02T09:22:55Z</dc:date>
    </item>
  </channel>
</rss>

