<?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>script Archives - CNERIS</title>
	<atom:link href="https://cneris.com/en/tag/script-en/feed/" rel="self" type="application/rss+xml" />
	<link>https://cneris.com/en/tag/script-en/</link>
	<description></description>
	<lastBuildDate>Thu, 22 Aug 2024 22:23:43 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
	<item>
		<title>Creating a script for monitoring the free space in the disk and sending an email in case of need</title>
		<link>https://cneris.com/en/creating-a-script-for-monitoring-the-free-space-in-the-disk-and-sending-an-email-in-case-of-needcreating-a-script-for-monitoring-the-free-space-in-the-disk-and-sending-an-email-in-case-of-need/</link>
					<comments>https://cneris.com/en/creating-a-script-for-monitoring-the-free-space-in-the-disk-and-sending-an-email-in-case-of-needcreating-a-script-for-monitoring-the-free-space-in-the-disk-and-sending-an-email-in-case-of-need/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 22 Aug 2024 22:23:43 +0000</pubDate>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[free space in the disk]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sending an email]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=1995</guid>

					<description><![CDATA[<p>Monitoring disk space is crucial to ensure that servers and systems do not run out of space, which could lead to data loss or system failures. In this article, you will learn how to create a Bash script that monitors disk space and sends an email notification when the available space falls below a specific [...]</p>
<p>The post <a href="https://cneris.com/en/creating-a-script-for-monitoring-the-free-space-in-the-disk-and-sending-an-email-in-case-of-needcreating-a-script-for-monitoring-the-free-space-in-the-disk-and-sending-an-email-in-case-of-need/">Creating a script for monitoring the free space in the disk and sending an email in case of need</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Monitoring disk space is crucial to ensure that servers and systems do not run out of space, which could lead to data loss or system failures. In this article, you will learn how to create a Bash script that monitors disk space and sends an email notification when the available space falls below a specific threshold.<br />
Steps to Create the Script<br />
1. Create the Bash Script:<br />
Create a script file, for example, `monitor_space.sh`:<br />
&#8220;`bash<br />
#!/bin/bash</p>
<p># Configuration<br />
THRESHOLD=20 # Minimum percentage of free disk space<br />
EMAIL=&#8221;youremail@example.com&#8221;</p>
<p># Get the percentage of free disk space<br />
FREE_SPACE=$(df / | grep / | awk &#8216;{ print $4 }&#8217; | sed &#8216;s/%//g&#8217;)</p>
<p># Check if free space is below the threshold<br />
if [ &#8220;$FREE_SPACE&#8221; -lt &#8220;$THRESHOLD&#8221; ]; then<br />
# Send warning email<br />
echo &#8220;Warning: Disk space is below $THRESHOLD%. Available space: $FREE_SPACE%.&#8221; | mail -s &#8220;Alert: Low Disk Space&#8221; $EMAIL<br />
fi<br />
&#8220;`</p>
<p>2. Set Permissions:<br />
Make sure the script has execution permissions:<br />
&#8220;`bash<br />
chmod +x monitor_space.sh<br />
&#8220;`</p>
<p>3. Configure Cron Job:<br />
To run the script periodically, you can set it up in cron:<br />
&#8220;`bash<br />
crontab -e<br />
&#8220;`<br />
Add the following line to run the script every hour:<br />
&#8220;`bash<br />
0 * * * * /path/to/script/monitor_space.sh<br />
&#8220;`</p>
<p>Conclusion<br />
With this simple script, you can effectively monitor disk space and receive email alerts when space is low, allowing you to take preventive actions.</p>
<p>The post <a href="https://cneris.com/en/creating-a-script-for-monitoring-the-free-space-in-the-disk-and-sending-an-email-in-case-of-needcreating-a-script-for-monitoring-the-free-space-in-the-disk-and-sending-an-email-in-case-of-need/">Creating a script for monitoring the free space in the disk and sending an email in case of need</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/en/creating-a-script-for-monitoring-the-free-space-in-the-disk-and-sending-an-email-in-case-of-needcreating-a-script-for-monitoring-the-free-space-in-the-disk-and-sending-an-email-in-case-of-need/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
