

<?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>ShareDigest blog &#187; cron</title>
	<atom:link href="http://blog.sharedigest.com/tag/cron/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sharedigest.com</link>
	<description>Trading, software, web and random stuff</description>
	<lastBuildDate>Tue, 06 Jul 2010 11:30:16 +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>Cron Task For Automated Backups</title>
		<link>http://blog.sharedigest.com/cron-task-for-automated-backups/</link>
		<comments>http://blog.sharedigest.com/cron-task-for-automated-backups/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 20:56:46 +0000</pubDate>
		<dc:creator>SD</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[automated backup]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[cron job]]></category>
		<category><![CDATA[linux shell script]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://blog.sharedigest.com/?p=111</guid>
		<description><![CDATA[


What we&#8217;re going to cover in this tutorial, is how to set up a cron job on a Centos 5  linux server. The basic problem I had, was that our server&#8217;s /backup/cpbackup/ folder was getting filled with (automated) backups very fast, taking up tonnes of disk space very quickly (only 7.5GB total available on [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td width="50%">
What we&#8217;re going to cover in this tutorial, is how to set up a cron job on a Centos 5  linux server. The basic problem I had, was that our server&#8217;s /backup/cpbackup/ folder was getting filled with (automated) backups very fast, taking up tonnes of disk space very quickly (only 7.5GB total available on this VPS! &#8211; perhaps time to look for a better one?). We&#8217;ll learn how to use cron jobs here to achieve the following:</p>
</td>
<td width="50%">
<div align="right">
<script type="text/javascript"><!--
google_ad_client = "pub-1739519678603459";
/* SDblog_300_250, created 9/24/09 */
google_ad_slot = "6287581496";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</td>
</tr>
</table>
<ul>
<li>Execute a script at a specified time once a week, which peforms the following:</li>
<li>Create a zipped-tar backup of the folder /backup/cpbackup/ at /backup/cpbackup_ddmmyy.tar.gz</li>
<li>Clear the entire /backup/cpbackup/ folder of all contents, freeing up this space</li>
<li>Email the administrator that the new backup_x.tar.gz file has been created</li>
<li>(Optionally): Automatically copy this file over to another (larger capacity) server</li>
</ul>
<p><strong>Step 1: Install A Cron Task</strong></p>
<p>A great little tutorial showing exactly how easy it is to install a cron task on any linux system, can be found <a href="http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/" target="_blank">here</a>.</p>
<p><strong>Step 2: Create the Shell Script</strong></p>
<p>The script which performs the magic, looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">#!/bin/sh
# Create a zipped-tar backup of the folder /backup/cpbackup/ at /backup/cpbackup_ddmmyy.tar.gz
# Clear the entire /backup/cpbackup/ folder of all contents, freeing up this space
# Email the administrator that the new backup_x.tar.gz file has been created
# (Optionally): Automatically copy this file over to another (larger capacity) server
&nbsp;
EMAIL=&quot;youremail@gmail.com&quot;
NOW=$(date +&quot;%d-%b-%y_%H%M&quot;)
BFILE=&quot;/backup/wz_cbackup_$NOW.tar.gz&quot;
MSG=&quot;&quot;
SUBJECT=&quot;&quot;
&nbsp;
#create tar zip file:
tar -czf $BFILE /backup/cpbackup/
&nbsp;
if [ &quot;$?&quot; -ne &quot;0&quot; ]; then
	MSG=&quot;tar -czf $BFILE /backup/cpbackup/ failed.&quot;
	SUBJECT=&quot;weeklyZip: $BFILE creation failed!&quot;
else
  	MSG=&quot;$BFILE successfully created. Please either download or copy to new server.&quot;
  	SUBJECT=&quot;weeklyZip: $BFILE  successfully created.&quot;
&nbsp;
	#Success, so we clear out the /backup/cpbackup/ folder:
	rm -R /backup/cpbackup/* -f
fi
&nbsp;
/bin/mail -s &quot;$SUBJECT&quot; &quot;$EMAIL&quot; &amp;lt;&amp;lt;&amp;lt; &quot;$MSG&quot;</pre></div></div>

<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-1739519678603459";
/* SDblog_300_250, created 9/24/09 */
google_ad_slot = "6287581496";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.sharedigest.com/subversion-using-apache-and-ssl/" rel="bookmark">Subversion Using Apache And SSL</a></li><li><a href="http://blog.sharedigest.com/handy-linux-commands/" rel="bookmark">Handy Linux Commands</a></li><li><a href="http://blog.sharedigest.com/handy-subversion-commands/" rel="bookmark">Handy Subversion Commands</a></li><li><a href="http://blog.sharedigest.com/linux-shell-scripting-check-if-folder-exists/" rel="bookmark">Linux Shell Scripting: Check if Folder Exists</a></li><li><a href="http://blog.sharedigest.com/algo-trading-101-part-1-getting-started/" rel="bookmark">Algo-Trading 101 Part 1: Getting Started</a></li></ul></div><hr /><h2>Related posts:</h2><ul><li><a href="http://blog.sharedigest.com/algo-trading-101-part-1-getting-started/" rel="bookmark" title="Permanent Link: Algo-Trading 101 Part 1: Getting Started">Algo-Trading 101 Part 1: Getting Started</a></li><li><a href="http://blog.sharedigest.com/the-stock-market-basics/" rel="bookmark" title="Permanent Link: The Stock Market: Basics">The Stock Market: Basics</a></li><li><a href="http://blog.sharedigest.com/australian-market-news-thursday-march-18/" rel="bookmark" title="Permanent Link: Thursday, March 18">Thursday, March 18</a></li><li><a href="http://blog.sharedigest.com/australian-market-news-thursday-march-18/" rel="bookmark" title="Permanent Link: Thursday, March 18">Thursday, March 18</a></li><li><a href="http://blog.sharedigest.com/australian-market-news-thursday-march-18/" rel="bookmark" title="Permanent Link: Thursday, March 18">Thursday, March 18</a></li></ul><hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://blog.sharedigest.com/cron-task-for-automated-backups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

