<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Script on Jose Castrillo</title>
    <link>https://jose.castrillo.eu/tags/script/</link>
    <description>Recent content in Script on Jose Castrillo</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Thu, 25 Apr 2019 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://jose.castrillo.eu/tags/script/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Output IPCONFIG report to HTML by PowerShell</title>
      <link>https://jose.castrillo.eu/post/report_script_powershell/</link>
      <pubDate>Thu, 25 Apr 2019 00:00:00 +0000</pubDate>
      <guid>https://jose.castrillo.eu/post/report_script_powershell/</guid>
      <description>&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$file = &amp;#34;C:\Users\jcr\a.html&amp;#34;
$ipconfig=ipconfig /all |%{&amp;#34;$_&amp;lt;br/&amp;gt;&amp;#34;}

$body=@&amp;#34;
&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Network Report&amp;lt;/title&amp;gt;
    &amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;IPConfig /All&amp;lt;/h1&amp;gt;
    &amp;lt;pre&amp;gt;$ipconfig&amp;lt;/pre&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&amp;#34;@
$body | Out-File $file
. $file
&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Create a job using crontab</title>
      <link>https://jose.castrillo.eu/post/cron-script-linux/</link>
      <pubDate>Wed, 03 Apr 2019 00:00:00 +0000</pubDate>
      <guid>https://jose.castrillo.eu/post/cron-script-linux/</guid>
      <description>&lt;p&gt;To automate tasks or create some monitoring job we can use the older and efficient tool the &amp;ldquo;CronJob&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;For our example, I&amp;rsquo;ve created a simple script to detect the cache memory and clean it if raise to a condition then send a notification by mail.&lt;/p&gt;
&lt;p&gt;Library used:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;exim4 (mail server) or ssmtp (mail server). Both uses the same &amp;ldquo;mail&amp;rdquo; command.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Script:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# grab the buff/cache memory
mem=&amp;#34;$(free -m | grep &amp;#39;Mem:&amp;#39; | awk &amp;#39;{print $6}&amp;#39;)&amp;#34;

if  (( $mem &amp;gt; 350 ))
then
echo &amp;#39;wooo is more than 250M&amp;#39;
echo 3 | sudo tee /proc/sys/vm/drop_caches
echo &amp;#39;cache dropped&amp;#39;
echo &amp;#34;Memory buff/cache cleaned last value:&amp;#34; $mem | mail -s &amp;#34;cache_memory&amp;#34; target_mail@local.com
else
echo &amp;#39;be cool man, memory lower&amp;#39;
fi
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;script path: /user/Documents/script/memory&lt;/strong&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
