<?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: execute cronjob @ 10 second intervals ? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/execute-cronjob-10-second-intervals/m-p/3318499#M186992</link>
    <description>&lt;BR /&gt;Looks like what you really want is realtime vmstat information.&lt;BR /&gt; &lt;BR /&gt;You could do what you want by changing your method.&lt;BR /&gt; &lt;BR /&gt;Let say you want 10 second data between 8 and 5 daily or 9 hours of 10 second data during prime time.&lt;BR /&gt;&lt;BR /&gt;kick off you cron shellb at 08:00&lt;BR /&gt;&lt;BR /&gt;The shell would look something like:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/usr/bin/vmstat 10 3240 |awk '($0 !~ /p/) {printf "%d%s\n", ($5*4)/1024, "MB" }'  &amp;gt;&amp;gt; logfile&lt;BR /&gt;&lt;BR /&gt;the 3240 is how many  10 second intervals in 9 hours.  You cauld tail or look at the logfile.  and get the most current value.&lt;BR /&gt;Also this will give you less overhead of trying to start a cron job a bunch of time.&lt;BR /&gt;Why sleep 10 when vmstat has the parm&lt;BR /&gt;the $0 !~ /p/ is a way to remove the header&lt;BR /&gt;with thought you probably think of something better. &lt;BR /&gt;&lt;BR /&gt;Rory&lt;BR /&gt;</description>
    <pubDate>Thu, 01 Jul 2004 11:30:22 GMT</pubDate>
    <dc:creator>Rory R Hammond</dc:creator>
    <dc:date>2004-07-01T11:30:22Z</dc:date>
    <item>
      <title>execute cronjob @ 10 second intervals ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/execute-cronjob-10-second-intervals/m-p/3318494#M186987</link>
      <description>Hello All,&lt;BR /&gt;&lt;BR /&gt;*********************************&lt;BR /&gt;HP-UX B.11.11 U 9000/800/N4000-75&lt;BR /&gt;*********************************&lt;BR /&gt;I'm trying to find a way to execute a cronjob&lt;BR /&gt;with 10 seconds intervals ? I know it can be&lt;BR /&gt;executed at minute intervals.&lt;BR /&gt;&lt;BR /&gt;The (2) commands I have in a script gather information related to "free memory &amp;amp; cpu info" are as follows:&lt;BR /&gt;1)/usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'&lt;BR /&gt;&lt;BR /&gt;2)/usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}'&lt;BR /&gt;&lt;BR /&gt;Please advised if this is possible, as always&lt;BR /&gt;thanks.</description>
      <pubDate>Tue, 29 Jun 2004 16:56:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/execute-cronjob-10-second-intervals/m-p/3318494#M186987</guid>
      <dc:creator>Jerry L. Sims</dc:creator>
      <dc:date>2004-06-29T16:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: execute cronjob @ 10 second intervals ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/execute-cronjob-10-second-intervals/m-p/3318495#M186988</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;  I dont think it is possible with cron.&lt;BR /&gt; &lt;BR /&gt;  Alternate way is to write a script&lt;BR /&gt;&lt;BR /&gt;  #!/usr/bin/sh&lt;BR /&gt;  while true&lt;BR /&gt;  do&lt;BR /&gt;    /usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }' &amp;gt;&amp;gt; /tmp/vmstat1.out&lt;BR /&gt;    /usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}' &amp;gt;&amp;gt; /tmp/vmstat2.out&lt;BR /&gt;    sleep 10&lt;BR /&gt;  done&lt;BR /&gt;&lt;BR /&gt;  run the script with nohup and in the backup&lt;BR /&gt;&lt;BR /&gt;  # nohup /usr/local/bin/&lt;ABOVE-SCRIPT&gt;&lt;/ABOVE-SCRIPT&gt;  &lt;BR /&gt;Sundar  &lt;BR /&gt;</description>
      <pubDate>Tue, 29 Jun 2004 17:05:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/execute-cronjob-10-second-intervals/m-p/3318495#M186988</guid>
      <dc:creator>Sundar_7</dc:creator>
      <dc:date>2004-06-29T17:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: execute cronjob @ 10 second intervals ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/execute-cronjob-10-second-intervals/m-p/3318496#M186989</link>
      <description>crons granularity is in minutes. if you want to run something more frequent than that, you will need to build the functionality yourself.&lt;BR /&gt;&lt;BR /&gt;simplest is to use "sleep n" command where machine will wait doing nothing in a a script for n-seconds when it hits this command, but it does not actually make running your command every 10 seconds. it will be 10 seconds between two command executions plus how ever many seconds the command needs to run.&lt;BR /&gt;&lt;BR /&gt;to accomplish running your commands every 10 seconds you can use a construct like this :&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;while true &lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;chkstr=`date +%S` # will give you the seconds from the date string&lt;BR /&gt;&lt;BR /&gt;case "$chkstr" in&lt;BR /&gt;&lt;BR /&gt;00) /usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'&lt;BR /&gt;    /usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}'&lt;BR /&gt;    break ;;&lt;BR /&gt;&lt;BR /&gt;10) /usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'&lt;BR /&gt;    /usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}'&lt;BR /&gt;    break ;;&lt;BR /&gt;&lt;BR /&gt;20) /usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'&lt;BR /&gt;    /usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}'&lt;BR /&gt;    break ;;&lt;BR /&gt;&lt;BR /&gt;30) /usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'&lt;BR /&gt;    /usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}'&lt;BR /&gt;    break ;;&lt;BR /&gt;&lt;BR /&gt;40) /usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'&lt;BR /&gt;    /usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}'&lt;BR /&gt;    break ;;&lt;BR /&gt;&lt;BR /&gt;50) /usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'&lt;BR /&gt;    /usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}'&lt;BR /&gt;    break ;;&lt;BR /&gt;&lt;BR /&gt;*) sleep 1&lt;BR /&gt;   break ;;&lt;BR /&gt;&lt;BR /&gt;esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Hope this helps</description>
      <pubDate>Tue, 29 Jun 2004 17:15:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/execute-cronjob-10-second-intervals/m-p/3318496#M186989</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2004-06-29T17:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: execute cronjob @ 10 second intervals ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/execute-cronjob-10-second-intervals/m-p/3318497#M186990</link>
      <description>You can rather simplify the construct as follows&lt;BR /&gt;&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;SECS=$(date +%S)&lt;BR /&gt;case "$SECS" in&lt;BR /&gt;[0-5]0) &lt;COMMANDS&gt;&lt;BR /&gt;        sleep 1&lt;BR /&gt;        ;;&lt;BR /&gt;*)      continue ;;&lt;BR /&gt;esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I am not sure if a loop will executed only once in a second !! , so I included a sleep right after the case statement and not in the default section.&lt;/COMMANDS&gt;</description>
      <pubDate>Tue, 29 Jun 2004 17:27:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/execute-cronjob-10-second-intervals/m-p/3318497#M186990</guid>
      <dc:creator>Sundar_7</dc:creator>
      <dc:date>2004-06-29T17:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: execute cronjob @ 10 second intervals ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/execute-cronjob-10-second-intervals/m-p/3318498#M186991</link>
      <description>OK. I just realized I was testing my construct with some simple echo commands and interestingly my loop executed more than once in a second :-)&lt;BR /&gt;&lt;BR /&gt;Since you have vmstat commands, you dont need a sleep in the case statements and can aswell have it in the default section.</description>
      <pubDate>Tue, 29 Jun 2004 17:29:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/execute-cronjob-10-second-intervals/m-p/3318498#M186991</guid>
      <dc:creator>Sundar_7</dc:creator>
      <dc:date>2004-06-29T17:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: execute cronjob @ 10 second intervals ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/execute-cronjob-10-second-intervals/m-p/3318499#M186992</link>
      <description>&lt;BR /&gt;Looks like what you really want is realtime vmstat information.&lt;BR /&gt; &lt;BR /&gt;You could do what you want by changing your method.&lt;BR /&gt; &lt;BR /&gt;Let say you want 10 second data between 8 and 5 daily or 9 hours of 10 second data during prime time.&lt;BR /&gt;&lt;BR /&gt;kick off you cron shellb at 08:00&lt;BR /&gt;&lt;BR /&gt;The shell would look something like:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/usr/bin/vmstat 10 3240 |awk '($0 !~ /p/) {printf "%d%s\n", ($5*4)/1024, "MB" }'  &amp;gt;&amp;gt; logfile&lt;BR /&gt;&lt;BR /&gt;the 3240 is how many  10 second intervals in 9 hours.  You cauld tail or look at the logfile.  and get the most current value.&lt;BR /&gt;Also this will give you less overhead of trying to start a cron job a bunch of time.&lt;BR /&gt;Why sleep 10 when vmstat has the parm&lt;BR /&gt;the $0 !~ /p/ is a way to remove the header&lt;BR /&gt;with thought you probably think of something better. &lt;BR /&gt;&lt;BR /&gt;Rory&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Jul 2004 11:30:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/execute-cronjob-10-second-intervals/m-p/3318499#M186992</guid>
      <dc:creator>Rory R Hammond</dc:creator>
      <dc:date>2004-07-01T11:30:22Z</dc:date>
    </item>
  </channel>
</rss>

