<?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>bash &#8211; VeriTeknik</title>
	<atom:link href="https://www.veriteknik.net.tr/en/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.veriteknik.net.tr/en/</link>
	<description>VeriTeknik Bilişim &#124; VeriTeknik Bilişim</description>
	<lastBuildDate>Mon, 09 Apr 2012 06:51:41 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Adding Job to Crontab Using BASH</title>
		<link>https://www.veriteknik.net.tr/en/adding-job-to-crontab-using-bash/</link>
					<comments>https://www.veriteknik.net.tr/en/adding-job-to-crontab-using-bash/#respond</comments>
		
		<dc:creator><![CDATA[Mustafa Emre Aydın]]></dc:creator>
		<pubDate>Mon, 09 Apr 2012 06:51:41 +0000</pubDate>
				<category><![CDATA[LINUX]]></category>
		<category><![CDATA[LINUX Help]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[crontab]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">http://www.plugged.in/?p=253</guid>

					<description><![CDATA[<p>Adding a task into crontab is relatively easy. You just enter the crontab with &#8220;$ crontab -e&#8221; and add the necessary job, save and exit. But adding a job in your bash script is not that simple, because what you have to do is, to get the entire list of the jobs, append your new [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/adding-job-to-crontab-using-bash/">Adding Job to Crontab Using BASH</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Adding a task into crontab is relatively easy. You just enter the crontab with &#8220;$ crontab -e&#8221; and add the necessary job, save and exit.</p>
<p>But adding a job in your bash script is not that simple, because what you have to do is, to get the entire list of the jobs, append your new job and save them as a whole.</p>
<p>Here&#8217;s a snippet of how to do that. Here, we assume that we want to run a script called &#8220;myscript.sh&#8221; every 5 minutes and the full path of the script is &#8220;$my_path/myscript.sh&#8221;. Don&#8217;t forget that in everycase, adding a job to crontab you have to specify the full path!</p>
<p>So basically, add these lines to your script.</p>
<pre class="brush: bash; gutter: true; first-line: 1">command="$my_path/myscript.sh" &gt; /dev/null 2&gt;&amp;1"
job="* /5 * * * * $command"
cat &lt;(grep -i -v "$command" &lt;(crontab -l)) &lt;(echo "$job") | crontab -</pre>
<p>Note that this is for <strong>BASH</strong>, not <strong>SH</strong>, since the syntax with the brackets is only available in BASH.</p>
<p>As you can see, the last line is the critical one. In the first brackets using the grep tool, we catch everything currently in the crontab &#8220;except our command&#8221;, so this will prevent from adding the $command even if it is already in crontab. After that, we echo our job to the end of the current jobs, and redirect it to cat as a standart input. Since the standart output of cat will be the whole crontab list &#8220;with our new job&#8221;, we can use crontab with its &#8220;-&#8221; option to get the arguments from the stadart output.</p>
<p>Hope this helps.</p>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/adding-job-to-crontab-using-bash/">Adding Job to Crontab Using BASH</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.veriteknik.net.tr/en/adding-job-to-crontab-using-bash/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">253</post-id>	</item>
		<item>
		<title>A Bash Script to Detect OS Info</title>
		<link>https://www.veriteknik.net.tr/en/a-bash-script-to-detect-os-info/</link>
					<comments>https://www.veriteknik.net.tr/en/a-bash-script-to-detect-os-info/#respond</comments>
		
		<dc:creator><![CDATA[Mustafa Emre Aydın]]></dc:creator>
		<pubDate>Sun, 04 Mar 2012 11:22:59 +0000</pubDate>
				<category><![CDATA[LINUX]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">http://www.plugged.in/?p=229</guid>

					<description><![CDATA[<p>Here&#8217;s a simple bash script snippet I use for detecting the OS information on the current system. #!/bin/bash ### Getting OS Information if [ -f /etc/lsb-release ]; then . /etc/lsb-release DIST=$DISTRIB_ID DIST_VER=$DISTRIB_RELEASE else DIST="Unknown" DIST_VER="Unknown" fi if [ -f /etc/debian_version ]; then OS="Debian" VER=$(cat /etc/debian_version) elif [ -f /etc/redhat-release ]; then OS="Red Hat" VER=$(cat /etc/redhat-release) [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/a-bash-script-to-detect-os-info/">A Bash Script to Detect OS Info</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Here&#8217;s a simple bash script snippet I use for detecting the OS information on the current system.</p>
<pre class="brush: bash; gutter: true; first-line: 1">#!/bin/bash
### Getting OS Information
if [ -f /etc/lsb-release ]; then
. /etc/lsb-release
DIST=$DISTRIB_ID
DIST_VER=$DISTRIB_RELEASE
else
DIST="Unknown"
DIST_VER="Unknown"
fi
if [ -f /etc/debian_version ]; then
OS="Debian"
VER=$(cat /etc/debian_version)
elif [ -f /etc/redhat-release ]; then
OS="Red Hat"
VER=$(cat /etc/redhat-release)
elif [ -f /etc/SuSE-release ]; then
OS="SuSE"
VER=$(cat /etc/SuSE-release)
else
OS=$(uname -s)
VER=$(uname -r)
fi</pre>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/a-bash-script-to-detect-os-info/">A Bash Script to Detect OS Info</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.veriteknik.net.tr/en/a-bash-script-to-detect-os-info/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">229</post-id>	</item>
	</channel>
</rss>
