<?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: Crontab Filtering in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281241#M688652</link>
    <description>This some light on a possible perl solution. It is not perfect but it works.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;$numArgs = $#ARGV + 1;&lt;BR /&gt;&lt;BR /&gt;foreach $argnum (0 .. $#ARGV) {&lt;BR /&gt;&lt;BR /&gt;        $argument=@ARGV[$argnum];&lt;BR /&gt;&lt;BR /&gt;        if ($argument eq "-day" or $argument eq "-d") {&lt;BR /&gt;                if (@ARGV[$argnum+1] =~ m/^[0-9]+$/) {&lt;BR /&gt;                        $day=@ARGV[$argnum+1];&lt;BR /&gt;                } else {&lt;BR /&gt;                        print "@ARGV[$argnum] should only be followed by a digit.\n";&lt;BR /&gt;                        $exitcode=1;&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;        if ($argument eq "-hour" or $argument eq "-h") {&lt;BR /&gt;                if (@ARGV[$argnum+1] =~ m/^[0-9]+$/) {&lt;BR /&gt;                        $hour=@ARGV[$argnum+1];&lt;BR /&gt;                } else {&lt;BR /&gt;                        print "@ARGV[$argnum] should only be followed by a digit.\n";&lt;BR /&gt;                        $exitcode=2;&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;        if ($argument eq "-minut" or $argument eq "-m") {&lt;BR /&gt;                if (@ARGV[$argnum+1] =~ m/^[0-9]+$/) {&lt;BR /&gt;                        $minut=@ARGV[$argnum+1];&lt;BR /&gt;                } else {&lt;BR /&gt;                        print "@ARGV[$argnum] should only be followed by a digit.\n";&lt;BR /&gt;                        $exitcode=3;&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;        if ($argument eq "-month" or $argument eq "-M") {&lt;BR /&gt;                if (@ARGV[$argnum+1] =~ m/^[0-9]+$/) {&lt;BR /&gt;                        $month=@ARGV[$argnum+1];&lt;BR /&gt;                } else {&lt;BR /&gt;                        print "@ARGV[$argnum] should only be followed by a digit.\n";&lt;BR /&gt;                        $exitcode=4;&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;        if ($argument eq "-weekday" or $argument eq "-w") {&lt;BR /&gt;                if (@ARGV[$argnum+1] =~ m/^[0-9]+$/) {&lt;BR /&gt;                        $weekday=@ARGV[$argnum+1];&lt;BR /&gt;                } else {&lt;BR /&gt;                        print "@ARGV[$argnum] should only be followed by a digit.\n";&lt;BR /&gt;                        $exitcode=5;&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;if ($exitcode) {&lt;BR /&gt;        exit $exitcode;&lt;BR /&gt;} else {&lt;BR /&gt;        # Run your script&lt;BR /&gt;        print "$hour $minut $day $month $weekday\n";&lt;BR /&gt;}&lt;BR /&gt;</description>
    <pubDate>Wed, 15 Oct 2008 13:32:05 GMT</pubDate>
    <dc:creator>Jannik</dc:creator>
    <dc:date>2008-10-15T13:32:05Z</dc:date>
    <item>
      <title>Crontab Filtering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281234#M688645</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;We need to create a script to find all the programs or scripts running at a particular time from crontab.&lt;BR /&gt;&lt;BR /&gt;1. Should have an option to search by name or using Shell's meta characters.&lt;BR /&gt;2. Should have an option to search by Minute.&lt;BR /&gt;3. Should have an option to search my Hour.&lt;BR /&gt;4. Should have an option to search by day.&lt;BR /&gt;7. Should have an option to search by month.&lt;BR /&gt;8. Should have an option to search by Weekday.&lt;BR /&gt;&lt;BR /&gt;for Ex : filter.sh -h 22 -day 10 -f /var/spool/cron/crontab_file&lt;BR /&gt; The above script should display  all the scprits running at 22:00 and  10th of each month.  /var/spool/cron/crontab_file is sample crontab file.&lt;BR /&gt;&lt;BR /&gt;Could anyone throw some light on this?</description>
      <pubDate>Mon, 06 Oct 2008 12:12:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281234#M688645</guid>
      <dc:creator>SkBhat</dc:creator>
      <dc:date>2008-10-06T12:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: Crontab Filtering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281235#M688646</link>
      <description>You are going to have to write a program or a perl script if you are going to allow complex queries.&lt;BR /&gt;&lt;BR /&gt;If all you are doing is ANDing all of your options you might be able to grep and awk to select the fields.  But you would have to handle "*" and ",".</description>
      <pubDate>Mon, 06 Oct 2008 12:34:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281235#M688646</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-10-06T12:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: Crontab Filtering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281236#M688647</link>
      <description>Why can't you just look at the /var/adm/cron/log?  Why can't you just tail the log and grep for CMD?</description>
      <pubDate>Mon, 06 Oct 2008 13:02:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281236#M688647</guid>
      <dc:creator>Michael Steele_2</dc:creator>
      <dc:date>2008-10-06T13:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: Crontab Filtering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281237#M688648</link>
      <description>&lt;!--!*#--&gt;Dennis,&lt;BR /&gt;You can create complex queries using case statement and shift. It's not fool proof thou.&lt;BR /&gt;ex.&lt;BR /&gt;filter.sh -h 22 -day 10 -f file&lt;BR /&gt;&lt;BR /&gt;until [ -z $1 ]; do&lt;BR /&gt;   case $1 in &lt;BR /&gt;      -h)&lt;BR /&gt;      some_command $2&lt;BR /&gt;      break&lt;BR /&gt;      ;;&lt;BR /&gt;      -day)&lt;BR /&gt;      some_other_command $2 &lt;BR /&gt;      break&lt;BR /&gt;      ;;&lt;BR /&gt;      -f)&lt;BR /&gt;      some_third_command $2&lt;BR /&gt;      break&lt;BR /&gt;      ;;&lt;BR /&gt;   esac&lt;BR /&gt;   shift&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;This is untested (not near a machine) so I'm not 100% sure that break won't destroy the "until" statement. But there's ways around that too. You could just ignore doing a break and let it pass.&lt;BR /&gt;&lt;BR /&gt;But what you need is something that goes throu every line with a regexp and then sorts it out and I think it'll make a lot of nested if-else-then statements.&lt;BR /&gt;&lt;BR /&gt;But I think Michael has the better plan... cat/grep/tail/head the logfile and just get the dates from there.</description>
      <pubDate>Thu, 09 Oct 2008 06:51:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281237#M688648</guid>
      <dc:creator>Fredrik.eriksson</dc:creator>
      <dc:date>2008-10-09T06:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Crontab Filtering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281238#M688649</link>
      <description>&amp;gt;Fredrik: You can create complex queries using case statement and shift.&lt;BR /&gt;&lt;BR /&gt;This is not the complex query I had in mind.  I was thinking of combinations of queries 1 through 8 with AND and OR.  Possibly searching for multiple names or hours, etc.&lt;BR /&gt;It looks like yours does an OR.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;until [ -z $1 ]; do&lt;BR /&gt;&lt;BR /&gt;Typically I only use while and count parms.  Yours will fail if using "set -u".&lt;BR /&gt;while [ $# -gt 0 ]; do&lt;BR /&gt;&lt;BR /&gt;&amp;gt;that break won't destroy the "until" statement.&lt;BR /&gt;&lt;BR /&gt;I think you want to use just ";;" to terminate each case label.  break gets you out of the until.&lt;BR /&gt;Also, you need to do "shift 2".</description>
      <pubDate>Thu, 09 Oct 2008 10:41:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281238#M688649</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-10-09T10:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Crontab Filtering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281239#M688650</link>
      <description>&amp;gt; It looks like yours does an OR.&lt;BR /&gt;Agreed, it'll be tricky and quite long if you want it to take AND parameters. It is possible thou, that was just a quick example on how to get multiple parameters without the need to have them at the right position.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Also, you need to do "shift 2".&lt;BR /&gt;Not really, unless you have a case label that will match the parameter value.&lt;BR /&gt;Like having -2 as a case label whilest sending something like "file.sh -degrees -2" (in which case you're absolutely right, shift 2 would solve it).&lt;BR /&gt;&lt;BR /&gt;This is quite easily solved by always saying that you want --degrees instead of just -degrees :)&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Fredrik Eriksson</description>
      <pubDate>Thu, 09 Oct 2008 13:30:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281239#M688650</guid>
      <dc:creator>Fredrik.eriksson</dc:creator>
      <dc:date>2008-10-09T13:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Crontab Filtering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281240#M688651</link>
      <description>&lt;!--!*#--&gt;&amp;gt;Fredrik: unless you have a case label that will match the parameter value.&lt;BR /&gt;&lt;BR /&gt;I was talking about your example.  But it would be better to have two shifts in case you had various types of options taking different parms:&lt;BR /&gt;while [ $# -gt 0 ]; do&lt;BR /&gt;   case $1 in&lt;BR /&gt;   -h)&lt;BR /&gt;      some_command $2&lt;BR /&gt;      shift&lt;BR /&gt;      ;;&lt;BR /&gt;...&lt;BR /&gt;   *) echo "bad option: $1"&lt;BR /&gt;      ;;&lt;BR /&gt;   esac&lt;BR /&gt;   shift&lt;BR /&gt;done</description>
      <pubDate>Thu, 09 Oct 2008 22:38:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281240#M688651</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-10-09T22:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Crontab Filtering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281241#M688652</link>
      <description>This some light on a possible perl solution. It is not perfect but it works.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;$numArgs = $#ARGV + 1;&lt;BR /&gt;&lt;BR /&gt;foreach $argnum (0 .. $#ARGV) {&lt;BR /&gt;&lt;BR /&gt;        $argument=@ARGV[$argnum];&lt;BR /&gt;&lt;BR /&gt;        if ($argument eq "-day" or $argument eq "-d") {&lt;BR /&gt;                if (@ARGV[$argnum+1] =~ m/^[0-9]+$/) {&lt;BR /&gt;                        $day=@ARGV[$argnum+1];&lt;BR /&gt;                } else {&lt;BR /&gt;                        print "@ARGV[$argnum] should only be followed by a digit.\n";&lt;BR /&gt;                        $exitcode=1;&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;        if ($argument eq "-hour" or $argument eq "-h") {&lt;BR /&gt;                if (@ARGV[$argnum+1] =~ m/^[0-9]+$/) {&lt;BR /&gt;                        $hour=@ARGV[$argnum+1];&lt;BR /&gt;                } else {&lt;BR /&gt;                        print "@ARGV[$argnum] should only be followed by a digit.\n";&lt;BR /&gt;                        $exitcode=2;&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;        if ($argument eq "-minut" or $argument eq "-m") {&lt;BR /&gt;                if (@ARGV[$argnum+1] =~ m/^[0-9]+$/) {&lt;BR /&gt;                        $minut=@ARGV[$argnum+1];&lt;BR /&gt;                } else {&lt;BR /&gt;                        print "@ARGV[$argnum] should only be followed by a digit.\n";&lt;BR /&gt;                        $exitcode=3;&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;        if ($argument eq "-month" or $argument eq "-M") {&lt;BR /&gt;                if (@ARGV[$argnum+1] =~ m/^[0-9]+$/) {&lt;BR /&gt;                        $month=@ARGV[$argnum+1];&lt;BR /&gt;                } else {&lt;BR /&gt;                        print "@ARGV[$argnum] should only be followed by a digit.\n";&lt;BR /&gt;                        $exitcode=4;&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;        if ($argument eq "-weekday" or $argument eq "-w") {&lt;BR /&gt;                if (@ARGV[$argnum+1] =~ m/^[0-9]+$/) {&lt;BR /&gt;                        $weekday=@ARGV[$argnum+1];&lt;BR /&gt;                } else {&lt;BR /&gt;                        print "@ARGV[$argnum] should only be followed by a digit.\n";&lt;BR /&gt;                        $exitcode=5;&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;if ($exitcode) {&lt;BR /&gt;        exit $exitcode;&lt;BR /&gt;} else {&lt;BR /&gt;        # Run your script&lt;BR /&gt;        print "$hour $minut $day $month $weekday\n";&lt;BR /&gt;}&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Oct 2008 13:32:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/crontab-filtering/m-p/4281241#M688652</guid>
      <dc:creator>Jannik</dc:creator>
      <dc:date>2008-10-15T13:32:05Z</dc:date>
    </item>
  </channel>
</rss>

