<?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 Script in cron job kills needed processes in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955829#M787900</link>
    <description>I have a script running in cron that kills processes NOT attached to a terminal, i.e. with a question mark in the ps -ef output.  The script has a provision to exclude certain users like root, lp, application users.  I recently added one more ID to be excluded but it continues to kill his processes.  &lt;BR /&gt;Do I need to recycle cron?&lt;BR /&gt;Here is the script:&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;# kill_nonterm_procs&lt;BR /&gt;#&lt;BR /&gt;ps -ef | grep "?" &amp;gt; /tmp/RUNPROCS&lt;BR /&gt;cat /tmp/RUNPROCS | awk '{ print $1 }' &amp;gt; /tmp/RUNPROCS_USERS&lt;BR /&gt;cat /tmp/RUNPROCS_USERS |&lt;BR /&gt;        grep -v mfg     |&lt;BR /&gt;        grep -v mls     |&lt;BR /&gt;        grep -v root    |&lt;BR /&gt;        grep -v adusys  |&lt;BR /&gt;        grep -v pedi53  |&lt;BR /&gt;        grep -v pedi54  |&lt;BR /&gt;        grep -v lp      |&lt;BR /&gt;        grep -v tngadmin|&lt;BR /&gt;        grep -v ftp     |&lt;BR /&gt;        grep -v patrol  |&lt;BR /&gt;        grep -v patuser |&lt;BR /&gt;        grep -v jzbnvs  |&lt;BR /&gt;        grep -v grep    | sort -u  &amp;gt; /tmp/RUNPROCS_USERS_CLEAN&lt;BR /&gt;if [ -s /tmp/RUNPROCS_USERS_CLEAN ]&lt;BR /&gt;then&lt;BR /&gt;for i in `cat /tmp/RUNPROCS_USERS_CLEAN`&lt;BR /&gt;do&lt;BR /&gt;        echo `date` &amp;gt;&amp;gt;/tmp/GG&lt;BR /&gt;        echo `ps -fu $i | grep -v UID | grep "?"` &amp;gt;&amp;gt; /tmp/GG&lt;BR /&gt;        PROCS=`ps -fu $i | grep "?" | grep -v PID | grep -v grep | sort -u | awk '{print $2 }'`&lt;BR /&gt;if [ -n "$PROCS" ]&lt;BR /&gt;then&lt;BR /&gt;        kill -15 $PROCS&lt;BR /&gt;else&lt;BR /&gt;:&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;        rm /tmp/RUNPROCS&lt;BR /&gt;        rm /tmp/RUNPROCS_USERS&lt;BR /&gt;        rm /tmp/RUNPROCS_USERS_CLEAN&lt;BR /&gt;else&lt;BR /&gt;exit 2&lt;BR /&gt;fi&lt;BR /&gt;</description>
    <pubDate>Mon, 30 Jan 2006 11:56:06 GMT</pubDate>
    <dc:creator>George_231</dc:creator>
    <dc:date>2006-01-30T11:56:06Z</dc:date>
    <item>
      <title>Script in cron job kills needed processes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955829#M787900</link>
      <description>I have a script running in cron that kills processes NOT attached to a terminal, i.e. with a question mark in the ps -ef output.  The script has a provision to exclude certain users like root, lp, application users.  I recently added one more ID to be excluded but it continues to kill his processes.  &lt;BR /&gt;Do I need to recycle cron?&lt;BR /&gt;Here is the script:&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;# kill_nonterm_procs&lt;BR /&gt;#&lt;BR /&gt;ps -ef | grep "?" &amp;gt; /tmp/RUNPROCS&lt;BR /&gt;cat /tmp/RUNPROCS | awk '{ print $1 }' &amp;gt; /tmp/RUNPROCS_USERS&lt;BR /&gt;cat /tmp/RUNPROCS_USERS |&lt;BR /&gt;        grep -v mfg     |&lt;BR /&gt;        grep -v mls     |&lt;BR /&gt;        grep -v root    |&lt;BR /&gt;        grep -v adusys  |&lt;BR /&gt;        grep -v pedi53  |&lt;BR /&gt;        grep -v pedi54  |&lt;BR /&gt;        grep -v lp      |&lt;BR /&gt;        grep -v tngadmin|&lt;BR /&gt;        grep -v ftp     |&lt;BR /&gt;        grep -v patrol  |&lt;BR /&gt;        grep -v patuser |&lt;BR /&gt;        grep -v jzbnvs  |&lt;BR /&gt;        grep -v grep    | sort -u  &amp;gt; /tmp/RUNPROCS_USERS_CLEAN&lt;BR /&gt;if [ -s /tmp/RUNPROCS_USERS_CLEAN ]&lt;BR /&gt;then&lt;BR /&gt;for i in `cat /tmp/RUNPROCS_USERS_CLEAN`&lt;BR /&gt;do&lt;BR /&gt;        echo `date` &amp;gt;&amp;gt;/tmp/GG&lt;BR /&gt;        echo `ps -fu $i | grep -v UID | grep "?"` &amp;gt;&amp;gt; /tmp/GG&lt;BR /&gt;        PROCS=`ps -fu $i | grep "?" | grep -v PID | grep -v grep | sort -u | awk '{print $2 }'`&lt;BR /&gt;if [ -n "$PROCS" ]&lt;BR /&gt;then&lt;BR /&gt;        kill -15 $PROCS&lt;BR /&gt;else&lt;BR /&gt;:&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;        rm /tmp/RUNPROCS&lt;BR /&gt;        rm /tmp/RUNPROCS_USERS&lt;BR /&gt;        rm /tmp/RUNPROCS_USERS_CLEAN&lt;BR /&gt;else&lt;BR /&gt;exit 2&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Mon, 30 Jan 2006 11:56:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955829#M787900</guid>
      <dc:creator>George_231</dc:creator>
      <dc:date>2006-01-30T11:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Script in cron job kills needed processes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955830#M787901</link>
      <description>No need to recycle cron, but you do have to have it re-read your cron input.  Generally, it's done like this:&lt;BR /&gt;&lt;BR /&gt;crontabl -l &amp;gt; cronfile&lt;BR /&gt;edit cronfile to make changes&lt;BR /&gt;crontab cronfile&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Mon, 30 Jan 2006 11:57:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955830#M787901</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2006-01-30T11:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: Script in cron job kills needed processes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955831#M787902</link>
      <description>I'll take that back.  If you change the script that cron is executing, then the change should have been implemented immediately.  I would look for a flaw in your script logic instead.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Mon, 30 Jan 2006 11:59:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955831#M787902</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2006-01-30T11:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: Script in cron job kills needed processes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955832#M787903</link>
      <description>No need to recycle cron - should be able to just make the change - and the next time it is run - it will run the newest version of the script..&lt;BR /&gt;&lt;BR /&gt;Question is, why are you wanting to kill processes not attatched to a terminel?&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 30 Jan 2006 12:01:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955832#M787903</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2006-01-30T12:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: Script in cron job kills needed processes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955833#M787904</link>
      <description>Geoff,&lt;BR /&gt;I need to run this script every 30 minutes because there are thousands of users who connect to the server using a windows telnet client and do not log out.  Their session shows in "ps -ef" with a question mark.</description>
      <pubDate>Mon, 30 Jan 2006 12:13:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955833#M787904</guid>
      <dc:creator>George_231</dc:creator>
      <dc:date>2006-01-30T12:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: Script in cron job kills needed processes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955834#M787905</link>
      <description>Do those show up with a?&lt;BR /&gt;&lt;BR /&gt; who -p&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 30 Jan 2006 12:47:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955834#M787905</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2006-01-30T12:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Script in cron job kills needed processes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955835#M787906</link>
      <description>Sorry - that should be:&lt;BR /&gt;&lt;BR /&gt;who -du&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 30 Jan 2006 12:49:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955835#M787906</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2006-01-30T12:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Script in cron job kills needed processes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955836#M787907</link>
      <description>Just took a quick look - don't think who -du will help...do they show up with a "who" at all?&lt;BR /&gt;&lt;BR /&gt;Otherwise, the ps way may be the only way....&lt;BR /&gt;&lt;BR /&gt;Which user is it still killing?&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 30 Jan 2006 13:10:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955836#M787907</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2006-01-30T13:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: Script in cron job kills needed processes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955837#M787908</link>
      <description>After giving this a little extra though I think I would take a different approach.&lt;BR /&gt;&lt;BR /&gt;Instead of making an exclusion list and killing everyone else I think I would make an inclusion list, set up in a for loop, and use ps -fu instead of -ef&lt;BR /&gt;&lt;BR /&gt;That way you are certain that you are only killing user processes for those users its ok to kill those processes for and that your not missing that should be killed just because the processes happens to have one of your excluded strings in description.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;for user in user1 user2 user3 user4 user5&lt;BR /&gt;do&lt;BR /&gt;ps -fu $user | get process list to kill&lt;BR /&gt;kill process list&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Mon, 30 Jan 2006 13:25:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955837#M787908</guid>
      <dc:creator>Howard Marshall</dc:creator>
      <dc:date>2006-01-30T13:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Script in cron job kills needed processes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955838#M787909</link>
      <description>The processes to be killed do not show in "who -du" b ut only in "ps -ef"&lt;BR /&gt;The script works fine when run manually meaning it excludes the newly added user (in my case user "tngadmin").  &lt;BR /&gt;The problem occurs when run from cron.  I re-read the crontab file with "crontab -e" but it keeps killing the newly added to the exclusion list user "tngadmin".&lt;BR /&gt;So I am wondering if I need to recycle cron at a suitable time tonight!?</description>
      <pubDate>Mon, 30 Jan 2006 14:03:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955838#M787909</guid>
      <dc:creator>George_231</dc:creator>
      <dc:date>2006-01-30T14:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Script in cron job kills needed processes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955839#M787910</link>
      <description>No harm stop/starting cron - should be fine during the day - unless there is an issue with some cron job..&lt;BR /&gt;&lt;BR /&gt;/sbin/init.d/cron stop ; /sbin/init.d/cron start&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 30 Jan 2006 14:16:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955839#M787910</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2006-01-30T14:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Script in cron job kills needed processes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955840#M787911</link>
      <description>As others have stated, the is no need to recycle cron, its going to run the whatever the script says at the time it is run.&lt;BR /&gt;&lt;BR /&gt;I'd NOT delete the files in /tmp and see if the give you a clue as to which step in your script isn't excluding tngadmin and work forward from there.</description>
      <pubDate>Mon, 30 Jan 2006 14:32:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955840#M787911</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2006-01-30T14:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Script in cron job kills needed processes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955841#M787912</link>
      <description>I seriously doubt that stopping and restarting cron will have any effect.&lt;BR /&gt;&lt;BR /&gt;Usually problems arise in scripts run from cron because of sparse environments.  You get a VERY BASIC environment in cron.&lt;BR /&gt;&lt;BR /&gt;Why not try this:&lt;BR /&gt;&lt;BR /&gt;Modify the first line of the script to read&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh -x&lt;BR /&gt;&lt;BR /&gt;The '-x' will force you into 'debug mode'.  Then modify your cron job so that you get an e-mail with the results of the run.&lt;BR /&gt;&lt;BR /&gt;1 2 * * * scriptname 2&amp;gt;&amp;amp;1 | mailx -s "script output" youremailaddresshere&lt;BR /&gt;&lt;BR /&gt;Then have a look at what you received to see if you can trace where the problem lies.</description>
      <pubDate>Mon, 30 Jan 2006 14:41:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955841#M787912</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2006-01-30T14:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: Script in cron job kills needed processes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955842#M787913</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;Possible solution for the telnet users:&lt;BR /&gt;&lt;BR /&gt;1) Configure the applicaiton to terminate after a certain number of minutes of inactivity.&lt;BR /&gt;2) Configure the variable TMOUT for all users in their environment prior to running any application.&lt;BR /&gt;&lt;BR /&gt;These two steps will self terminate sessions that have been left idle.&lt;BR /&gt;&lt;BR /&gt;Good Luck,&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Mon, 30 Jan 2006 14:48:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955842#M787913</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2006-01-30T14:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Script in cron job kills needed processes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955843#M787914</link>
      <description>cat -e "script name" solved the problem.  Found  additional space in script.  I was running manually the same script but with no space. Thanks everybody.</description>
      <pubDate>Mon, 30 Jan 2006 15:16:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-in-cron-job-kills-needed-processes/m-p/4955843#M787914</guid>
      <dc:creator>George_231</dc:creator>
      <dc:date>2006-01-30T15:16:02Z</dc:date>
    </item>
  </channel>
</rss>

