<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LosByers- Interesting Musings Helpful Hints from a Unix System Administrator &#187; Script</title>
	<atom:link href="http://losbyers.com/wordpress/tag/script/feed/" rel="self" type="application/rss+xml" />
	<link>http://losbyers.com/wordpress</link>
	<description>All the info I need</description>
	<lastBuildDate>Fri, 10 Sep 2010 04:56:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Killing windows processes from the command line</title>
		<link>http://losbyers.com/wordpress/2009/12/killing-windows-processes-from-the-command-line/</link>
		<comments>http://losbyers.com/wordpress/2009/12/killing-windows-processes-from-the-command-line/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 20:33:33 +0000</pubDate>
		<dc:creator>LosByers</dc:creator>
				<category><![CDATA[Windows OS]]></category>
		<category><![CDATA[PC]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://losbyers.com/wordpress/?p=96</guid>
		<description><![CDATA[<p>Use TASKLIST and TASKKILL :  Good web site on this http://commandwindows.com/taskkill.htm</p>
<p>(F)orce Kill running processes for ImageName of java.exe
taskkill.exe /F /IM java.exe</p>
<p>NOTE: Wildcard &#8216;*&#8217; for the /IM switch is accepted only with filters, use /FI
taskkill /F /FI &#8220;IMAGENAME eq note*&#8221;</p>
<p>Find all running Java processes command line
tasklist /FI “IMAGENAME eq java.exe”</p>
<p>Example:  I started 2 Calculator programs.</p>
<p>H:\&#62;tasklist /FI [...]]]></description>
			<content:encoded><![CDATA[<p><span>Use TASKLIST and TASKKILL :  Good web site on this <a href="http://commandwindows.com/taskkill.htm" target="_blank">http://commandwindows.com/taskkill.htm</a></p>
<p>(F)orce Kill running processes for ImageName of java.exe<br />
taskkill.exe /F /IM java.exe</p>
<p>NOTE: Wildcard &#8216;*&#8217; for the /IM switch is accepted only with filters, use /FI<br />
taskkill /F /FI &#8220;IMAGENAME eq note*&#8221;</p>
<p>Find all running Java processes command line<br />
tasklist /FI “IMAGENAME eq java.exe”</p>
<p>Example:  I started 2 Calculator programs.</p>
<p>H:\&gt;tasklist /FI &#8220;IMAGENAME eq calc*&#8221;</p>
<pre>Image Name                   PID Session Name     Session#    Mem Usage
========================= ====== ================ ======== ============
calc.exe                    4652 Console                 0      3,420 K
calc.exe                    1936 Console                 0      3,412 K
</pre>
<p>H:\&gt;taskkill /F /FI &#8220;IMAGENAME eq calc*&#8221;<br />
SUCCESS: The process with PID 4652 has been terminated.<br />
SUCCESS: The process with PID 1936 has been terminated.</p>
<p>I needed these commands to script a nightly restart of a java application that had a bad memory leak.  For some reason the normal stop wasn&#8217;t working. <img title="Crying or Very sad" src="http://www.losbyers.com/modules/Forums/images/smiles/icon_cry.gif" border="0" alt="Crying or Very sad" /></span></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Flosbyers.com%2Fwordpress%2F2009%2F12%2Fkilling-windows-processes-from-the-command-line%2F&amp;linkname=Killing%20windows%20processes%20from%20the%20command%20line"><img src="http://losbyers.com/wordpress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://losbyers.com/wordpress/2009/12/killing-windows-processes-from-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Scheduled Task Log Output</title>
		<link>http://losbyers.com/wordpress/2009/12/windows-scheduled-task-log-output/</link>
		<comments>http://losbyers.com/wordpress/2009/12/windows-scheduled-task-log-output/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 18:26:35 +0000</pubDate>
		<dc:creator>LosByers</dc:creator>
				<category><![CDATA[Web Related]]></category>
		<category><![CDATA[BAT]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://losbyers.com/wordpress/?p=93</guid>
		<description><![CDATA[<p>I needed to have a script list and kill processes and I needed that script to run out of a scheduled task.</p>
<p>It would be nice to know what happened with the script when it runs early in the morning.</p>
<p>I found  that if you call the script from the Windows Task Scheduler that you can give [...]]]></description>
			<content:encoded><![CDATA[<p><span>I needed to have a script list and kill processes and I needed that script to run out of a scheduled task.</span></p>
<p>It would be nice to know what happened with the script when it runs early in the morning.</p>
<p>I found  that if you call the script from the Windows Task Scheduler that you can give the job a few more options.</p>
<p>Change the scheduled tasks to read as<br />
<span style="font-weight: bold;">cmd <span style="font-style: italic;">/C NightlyBatchJob.bat &gt; NightlyBatchJob.output.txt 2&gt;&amp;1</span></span></p>
<p>The output should be placed in the same directory as the script.</p>
<p><span>I also should include the script that stops all of the java processes for Wallstreet systems CMM/TRM application.</span></p>
<p><span><span id="more-93"></span></span></p>
<pre>
<pre>REM Win 2003 systems have the sleep command
REM sleep 40
REM XP systems don't.
REM The ping command times out at 20 seconds, goofy way to create a wait.
REM Comment out either the ping or the sleep depending on which works</pre>
<p>cd \&lt;install_path&gt;\pmm\bin</p>
<p>REM force PMAD/PMSD to start, in case they are not running<br />
net start "Wallstreet Suite - pmad"<br />
net start "Wallstreet Suite - pmsd"</p>
<p>.\pm_cmd admin_account/password@localhost:8887 stop SDM@test1<br />
.\pm_cmd admin_account/password@localhost:8887 stop ACM@test1<br />
.\pm_cmd admin_account/password@localhost:8887 stop websuite_appserver@test1<br />
.\pm_cmd admin_account/password@localhost:8887 stop WebSuite@test1<br />
.\pm_cmd admin_account/password@localhost:8887 stop cmm_tcmd_appserver@test1</p>
<p>REM sleep 40<br />
ping 10.10.10.254 &gt; NUL<br />
ping 10.10.10.254 &gt; NUL</p>
<p>.\pm_cmd admin_account/password@localhost:8887 stop TRM@test1</p>
<p>ping 10.10.10.254 &gt; NUL<br />
ping 10.10.10.254 &gt; NUL</p>
<p>.\pm_cmd admin_account/password@localhost:8887 stop messaging@test1<br />
.\pm_cmd admin_account/password@localhost:8887 stop active_mq@test1<br />
.\pm_cmd admin_account/password@localhost:8887 stop trm_mdsd@test1<br />
.\pm_cmd admin_account/password@localhost:8887 stop omninames@test1</p>
<p>REM Only stop  pmad/pmsd if really necessary<br />
REM net stop "Wallstreet Suite - pmsd"<br />
REM net stop "Wallstreet Suite - pmad"</p>
<p>REM sleep 20<br />
ping 10.10.10.254 &gt; NUL</p>
<p>REM Display processes status if needed<br />
.\pm_cmd admin_account/password@localhost:8887 proc</p>
<p>REM sleep 40<br />
ping 10.10.10.254 &gt; NUL<br />
ping 10.10.10.254 &gt; NUL</p>
<p>REM Make sure everything is down by killing any hung processes.<br />
.\pm_cmd admin_account/password@localhost:8887 kill WALLSTREET_SUITE@test1</p>
<p>REM sleep 40<br />
ping 10.10.10.254 &gt; NUL<br />
ping 10.10.10.254 &gt; NUL<br />
REM List out the remaining running tasks owned by SYSTEM<br />
tasklist /S localhost /U SYSTEM<br />
REM Kill any left over java processes. NOTE: will kill ALL JAVA processes on the system<br />
taskkill /F /FI "IMAGENAME eq java*"</pre>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Flosbyers.com%2Fwordpress%2F2009%2F12%2Fwindows-scheduled-task-log-output%2F&amp;linkname=Windows%20Scheduled%20Task%20Log%20Output"><img src="http://losbyers.com/wordpress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://losbyers.com/wordpress/2009/12/windows-scheduled-task-log-output/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Too many processes script</title>
		<link>http://losbyers.com/wordpress/2009/12/too-many-processes-script/</link>
		<comments>http://losbyers.com/wordpress/2009/12/too-many-processes-script/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 22:05:22 +0000</pubDate>
		<dc:creator>LosByers</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[KSH]]></category>
		<category><![CDATA[Script]]></category>

		<guid isPermaLink="false">http://losbyers.com/wordpress/?p=42</guid>
		<description><![CDATA[<p>KSH script to check the number of processes on a system and send an email if there are too many.</p>
<p>I liked this as it was simple, but had some nice elements that could be used elsewhere.</p>
<p>#!/bin/ksh
#
# Script to check for run away ftp processes.
# 04/08 &#8211; Mike Byers</p>
<p>HOST=`uname -n`
ADMINZ=&#8221;admin@somewhere.com&#8221;
# Add email Recipients
RECPTS=&#8221;email_add@somewhere.com&#8221;</p>
<p># Let the user [...]]]></description>
			<content:encoded><![CDATA[<p>KSH script to check the number of processes on a system and send an email if there are too many.</p>
<p>I liked this as it was simple, but had some nice elements that could be used elsewhere.</p>
<p><span style="color: #800080;">#!/bin/ksh<br />
#<br />
# Script to check for run away ftp processes.<br />
# 04/08 &#8211; Mike Byers</p>
<p>HOST=`uname -n`<br />
ADMINZ=&#8221;admin@somewhere.com&#8221;<br />
# Add email Recipients<br />
RECPTS=&#8221;email_add@somewhere.com&#8221;</p>
<p># Let the user pass an argument or default to ftp<br />
if [ $1 ];<br />
then<br />
APP=&#8221;$1&#8243;<br />
else<br />
APP=&#8221;ftp&#8221;<br />
fi</p>
<p>num=`ps -ea -o &#8216;user pid time pmem comm&#8217; | grep $APP | wc -l`</p>
<p>if  [ $num -gt 6 ];<br />
then<br />
# Do stuff if there are too many active processes.</p>
<p># echo &#8220;Number of processes is too many at $num &#8221;<br />
# Kill all active ftp processes<br />
# pkill -9 -n $APP</p>
<p># Send notification only<br />
echo &#8220;Number of $APP processes is too many at $num on $HOST for user $LOGNAME&#8221; | /bin/mailx -r $ADMINZ -s &#8220;Too many processes on $HOST for user $LOGNAME&#8221; $ADMINZ $RECPTS</p>
<p>fi</span></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Flosbyers.com%2Fwordpress%2F2009%2F12%2Ftoo-many-processes-script%2F&amp;linkname=Too%20many%20processes%20script"><img src="http://losbyers.com/wordpress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://losbyers.com/wordpress/2009/12/too-many-processes-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
