<?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>gHacks technology news &#187; cron</title>
	<atom:link href="http://www.ghacks.net/tag/cron/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ghacks.net</link>
	<description>A technology blog covering software, mobile phones, gadgets, security, the Internet and other relevant areas.</description>
	<lastBuildDate>Tue, 24 Nov 2009 11:26:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Linux Back In Time: Backup made easy</title>
		<link>http://www.ghacks.net/2009/10/10/linux-back-in-time-backup-made-easy/</link>
		<comments>http://www.ghacks.net/2009/10/10/linux-back-in-time-backup-made-easy/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 17:00:23 +0000</pubDate>
		<dc:creator>Jack Wallen</dc:creator>
				<category><![CDATA[Desktop Manager]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tutorials Basic]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[auto backups]]></category>
		<category><![CDATA[backups]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[desktop backup]]></category>

		<guid isPermaLink="false">http://www.ghacks.net/?p=17123</guid>
		<description><![CDATA[In my recent trend of covering Linux backup tools I have, so far, covered Flyback (&#8221;Quick and easy backups with Flyback&#8220;) and Backerupper (&#8221;Simple gui backup tool Backerupper&#8220;). Both tools are GUI tools that make the process of backing up your Linux files and folders a simple task. This time around I want to add [...]]]></description>
			<content:encoded><![CDATA[<p>In my recent trend of covering Linux backup tools I have, so far, covered Flyback (&#8221;<a title="Flyback" href="http://www.ghacks.net/2009/10/08/quick-and-easy-backups-with-flyback/" target="_blank">Quick and easy backups with Flyback</a>&#8220;) and Backerupper (&#8221;<a title="Backerupper" href="http://www.ghacks.net/2009/10/09/simple-gui-backup-tool-backerupper/" target="_blank">Simple gui backup tool Backerupper</a>&#8220;). Both tools are GUI tools that make the process of backing up your Linux files and folders a simple task. This time around I want to add to this growing list of user-friendly backup tools <a title="Back in time" href="http://backintime.le-web.org/" target="_blank">Back In Time</a>.</p>
<p>Back In Time offers two GUI versions: One for GNOME and one for KDE. If you want to run the KDE version of the tool you will have to be running KDE &gt;= 4.1. The difference between the GUIs is minimal, and there are no features on one that are on the other (it&#8217;s all in the different widget sets used.) <span style="background-color: #ffffff">In this tutorial you will learn how to install and use the Back In Time backup tool.</span></p>
<p><span style="background-color: #ffffff"><span id="more-17123"></span><strong>Installation</strong></span></p>
<p><span style="background-color: #ffffff">Installing Back In Time is simple. Go to the applications&#8217; <a title="Back In Time Download Page" href="http://backintime.le-web.org/download_page/" target="_blank">download page</a> and download the necessary files. If you are installing on Ubuntu you will need:</span></p>
<p><span style="background-color: #ffffff"><a title="backintime-common" href="http://backintime.le-web.org/download/backintime/backintime-common-0.9.26_all.deb" target="_blank">backintime-common</a></span></p>
<p><span style="background-color: #ffffff">and either:</span></p>
<p><span style="background-color: #ffffff"><a title="backintime-gnome" href="http://backintime.le-web.org/download/backintime/backintime-gnome-0.9.26_all.deb" target="_blank">backintime-gnome</a></span></p>
<p><span style="background-color: #ffffff">or</span></p>
<p><span style="background-color: #ffffff"><a title="backintime-kde" href="http://backintime.le-web.org/download/backintime/backintime-kde4-0.9.26_all.deb" target="_blank">backintime-kde</a></span></p>
<p>Before you can install this application you will need to first install the meld tool. To do this issue the command:</p>
<p><em>sudo apt-get install meld</em></p>
<p><span style="background-color: #ffffff">Once Meld is installed you can install Back In Time. To do this you just need to open up a terminal window, change to the directory you downloaded the files into, and issue the command:</span></p>
<p><span style="background-color: #ffffff"><em>sudo dpkg -i backintime*</em></span></p>
<p>which will install both necessary files.</p>
<p>After the application is installed you are ready to start backing up.</p>
<p><strong>Usage</strong></p>
<p>To start up Back In Time go to the System Tools sub-menu of the Applications menu. There ar two entries: Back In Time and Back  In Time (root). You will want to run the non-root entry to back up your standard files.</p>
<div id="attachment_17131" class="wp-caption alignleft" style="width: 250px"><a rel="attachment wp-att-17131" href="http://www.ghacks.net/2009/10/10/linux-back-in-time-backup-made-easy/backintime_settings/"><img class="size-thumbnail wp-image-17131 " src="http://www.ghacks.net/wp-content/uploads/2009/10/backintime_settings-300x300.png" alt="Figure 1" width="240" height="240" /></a><p class="wp-caption-text">Figure 1</p></div>
<p>When you fire up Back In Time for the first time you will be greeted, not with the main window, but the Settings Window (see Figure 1).  Before you can actually set up a back up you have to configure a backup directory. This is done in the General tab of the Settings window.</p>
<p>By default the Schedule will be disabled. This is fine if you want to do a one-time backup. But for scheduled backups you will need to select a frequency from the Schedule drop down.</p>
<p>You will also have to add at least one folder to back up. To do this go to the Include tab and add a directory to be backed up. You can, of course, add more than one directory to back up.</p>
<p>From within the Auto-remove tab in the Settings window there is a setting I highly recommend. If you check the &#8220;Smart Remove&#8221; check box Back In Time will:</p>
<ul>
<li><span style="background-color: #ffffff">Keep all snapshots from today and yesterday.</span></li>
<li><span style="background-color: #ffffff">Keep one snapshot from last week and one from two weeks prior.</span></li>
<li><span style="background-color: #ffffff">Keep one snapshot per month for all previous months of the year.</span></li>
<li><span style="background-color: #ffffff">Keep one snapshot per year for all previous years.</span></li>
</ul>
<p><span style="background-color: #ffffff">If you have any need to retain snapshots, this is a fairly safe bet.</span></p>
<p><span style="background-color: #ffffff">From within the Exclude tab you can configure Back In Time for folders and/or files to not include in the backup. You can also add patterns to exclude, which can include wildcards.</span></p>
<p><span style="background-color: #ffffff">After you have all of your settings taken care of click OK and Back In Time is set up and ready to go. </span></p>
<p><span style="background-color: #ffffff"><strong>What about that scheduled backup?</strong></span></p>
<p>Here&#8217;s the deal &#8211; Back In Time does not have a Panel icon to keep the application running in the background. So unless you plan on keeping the application open, you have to have another means to make sure your backups happen.  In order to do this you have to know the command line portion of the tool. And then you will need to add the right command as a cron job. Without getting too complicated, the command to run Back In Time from the command line will be:</p>
<p><em>backintime -b</em></p>
<p>Which will back up any necessary job you have created.</p>
<p>With that in mind you can set up the <em>backintime</em> command to be run from your crontab. Say, for example, you want your backintime job to run every Sunday. You could enter a cronjob (started by issuing the command <em>crontab -e</em>) and enter a job like:</p>
<p><em>* * * * 7 /usr/bin/backintime -b</em></p>
<p>Save that cron job and it will be set up to run every Sunday.</p>
<p><strong>Final thoughts</strong></p>
<p>Back In Time is just as user-friendly as the other backup tools and adds a command line tool for added flexibility. I highly recommend Back In Time for your simple desktop backup jobs.</p>
<p><span style="background-color: #ffffff"> </span></p>

	Tags: <a href="http://www.ghacks.net/tag/auto-backups/" title="auto backups" rel="tag">auto backups</a>, <a href="http://www.ghacks.net/tag/backups/" title="backups" rel="tag">backups</a>, <a href="http://www.ghacks.net/tag/cron/" title="cron" rel="tag">cron</a>, <a href="http://www.ghacks.net/tag/desktop-backup/" title="desktop backup" rel="tag">desktop backup</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.ghacks.net/2009/01/22/back-up-your-apache-web-directory-and-database-with-this-simple-script/" title="Back up your Apache web directory and database with this simple script (January 22, 2009)">Back up your Apache web directory and database with this simple script</a> (0)</li>
	<li><a href="http://www.ghacks.net/2007/10/13/zoogmo-secure-peer-to-peer-backups/" title="Zoogmo Secure Peer To Peer Backups (October 13, 2007)">Zoogmo Secure Peer To Peer Backups</a> (3)</li>
	<li><a href="http://www.ghacks.net/2009/01/12/verify-file-integrity-of-backups/" title="Verify File Integrity Of Backups (January 12, 2009)">Verify File Integrity Of Backups</a> (4)</li>
	<li><a href="http://www.ghacks.net/2009/01/11/using-cron-to-automate-linux-tasks/" title="Using Cron to Automate Linux Tasks (January 11, 2009)">Using Cron to Automate Linux Tasks</a> (7)</li>
	<li><a href="http://www.ghacks.net/2009/10/09/simple-gui-backup-tool-backerupper/" title="Simple gui backup tool backerupper (October 9, 2009)">Simple gui backup tool backerupper</a> (3)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.ghacks.net/2009/10/10/linux-back-in-time-backup-made-easy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Back up your Apache web directory and database with this simple script</title>
		<link>http://www.ghacks.net/2009/01/22/back-up-your-apache-web-directory-and-database-with-this-simple-script/</link>
		<comments>http://www.ghacks.net/2009/01/22/back-up-your-apache-web-directory-and-database-with-this-simple-script/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 18:58:34 +0000</pubDate>
		<dc:creator>Jack Wallen</dc:creator>
				<category><![CDATA[Advice]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tutorials Advanced]]></category>
		<category><![CDATA[Tutorials Basic]]></category>
		<category><![CDATA[automated backups]]></category>
		<category><![CDATA[backup-solution]]></category>
		<category><![CDATA[backups]]></category>
		<category><![CDATA[cat]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://www.ghacks.net/?p=10060</guid>
		<description><![CDATA[I administer a lot of web sites. And all of these web sites need backup solutions. Since most of those web sites use LAMP servers it only made sense to set up a backup system using the available, included open source tools. It didn&#8217;t take long to create a solid backup system and, with the [...]]]></description>
			<content:encoded><![CDATA[<p>I administer a lot of web sites. And all of these web sites need backup solutions. Since most of those web sites use LAMP servers it only made sense to set up a backup system using the available, included open source tools. It didn&#8217;t take long to create a solid backup system and, with the help of cron, automate that system so that Apache&#8217;s document root and the website databases were backed up regularly and without user intervention.</p>
<p>The script made use of the following tools: date, cat, tar, mv, and rm. That&#8217;s it. The script will create backups with the date in the file name and then move the backups to a central location. Without further adieu, let&#8217;s get to the script.</p>
<p><span id="more-10060"></span><em>#! /bin/sh</em></p>
<p><em>TMP=&#8221;/tmp/&#8221;</em></p>
<p><em>#Format the date in YEAR-MO-DY format<br />
TODAY=`date +%F`</em></p>
<p><em># Check to see if there is a lastbackup file in /tmp, if not create it,<br />
# if so then set LAST equal to $TODAY<br />
if [ -f /tmp/lastbackup ]; then<br />
LAST=`cat /tmp/lastbackup`<br />
else<br />
LAST=$TODAY<br />
fi</em></p>
<p><em># Set the web directory backup name to the following<br />
WEB_FILENAME=&#8221;inc-&#8221;$TODAY&#8221;-web.tar.gz&#8221;</em></p>
<p><em># Set database backup name to the following<br />
DB_FILENAME=&#8221;inc-&#8221;$TODAY&#8221;-db.tar.gz&#8221;</em></p>
<p><em># this tars up my web directory into web.tar.gz tarball.<br />
/bin/tar -czf $TMP$WEB_FILENAME &#8211;after-date=$LAST /var/www/html</em></p>
<p><em># Move the web back to the backup directory<br />
/bin/mv $TMP$WEB_FILENAME /data</em></p>
<p><em># Remove web backup file from temp director<br />
rm $TMP$WEB_FILENAME</em></p>
<p><em># this tars up my database directory into $TODAY-db.tar.gz tarball.<br />
/bin/tar -czf $TMP$DB_FILENAME &#8211;after-date=$LAST /var/lib/mysql</em></p>
<p><em># Move the backup database to the backup directory<br />
/bin/mv $TMP$DB_FILENAME /data</em></p>
<p><em># Remove web backup file from temp directory<br />
rm $TMP$DB_FILENAME<br />
</em></p>
<p>What I wanted this to do is create daily backups and move the backups to the <strong>/data</strong> directory on the drive housing the server. These backups will be saved for one month. After the month is completed i have a second script that deletes the months backups prior to running the next backup (so there is always a backup to fall to). How I made use of this script is simple. I save the script (called <strong>backup.sh</strong>) in the root user directory and create a second script called <strong>rm_backups.sh</strong> that looks like this:</p>
<p><em>#! /bin/sh</em></p>
<p><em>rm /data/*gz</em></p>
<p>With these two files in place I create two cron entries. The first cron entry is for running the <strong>backup.sh</strong> script and looks like:</p>
<p>0 23 * * *     ~/backup.sh</p>
<p>The second cron entry is for running the <strong>rm_backups.sh</strong> script and looks like:</p>
<p>0 20 1 * *     ~/rm_backups.sh</p>
<p>Both of the above cron jobs are created as the root user.</p>
<p><strong>Final Thoughts</strong></p>
<p>Naturally this solution could be easily modified (using such tools rsync) to set up an offsite backup solution. What should be obvious is that creating a simple, flexible server backup system on Linux is easy. With the help of a little ingenuity, you can create your own automated backup service.</p>

	Tags: <a href="http://www.ghacks.net/tag/automated-backups/" title="automated backups" rel="tag">automated backups</a>, <a href="http://www.ghacks.net/tag/backup-solution/" title="backup-solution" rel="tag">backup-solution</a>, <a href="http://www.ghacks.net/tag/backups/" title="backups" rel="tag">backups</a>, <a href="http://www.ghacks.net/tag/cat/" title="cat" rel="tag">cat</a>, <a href="http://www.ghacks.net/tag/cron/" title="cron" rel="tag">cron</a>, <a href="http://www.ghacks.net/tag/date/" title="date" rel="tag">date</a>, <a href="http://www.ghacks.net/tag/lamp/" title="LAMP" rel="tag">LAMP</a>, <a href="http://www.ghacks.net/tag/linux/" title="Linux" rel="tag">Linux</a>, <a href="http://www.ghacks.net/tag/tar/" title="tar" rel="tag">tar</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.ghacks.net/2009/01/11/using-cron-to-automate-linux-tasks/" title="Using Cron to Automate Linux Tasks (January 11, 2009)">Using Cron to Automate Linux Tasks</a> (7)</li>
	<li><a href="http://www.ghacks.net/2009/02/15/quick-archiving-in-gnome/" title="Quick Archiving in GNOME (February 15, 2009)">Quick Archiving in GNOME</a> (1)</li>
	<li><a href="http://www.ghacks.net/2009/10/10/linux-back-in-time-backup-made-easy/" title="Linux Back In Time: Backup made easy (October 10, 2009)">Linux Back In Time: Backup made easy</a> (1)</li>
	<li><a href="http://www.ghacks.net/2009/02/19/installing-firefox-and-flash-from-source/" title="Installing Firefox and Flash From Source (February 19, 2009)">Installing Firefox and Flash From Source</a> (8)</li>
	<li><a href="http://www.ghacks.net/2008/12/20/install-phpmyadmin-for-easy-mysql-administration/" title="Install phpmyadmin for easy MySQL administration (December 20, 2008)">Install phpmyadmin for easy MySQL administration</a> (6)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.ghacks.net/2009/01/22/back-up-your-apache-web-directory-and-database-with-this-simple-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Cron to Automate Linux Tasks</title>
		<link>http://www.ghacks.net/2009/01/11/using-cron-to-automate-linux-tasks/</link>
		<comments>http://www.ghacks.net/2009/01/11/using-cron-to-automate-linux-tasks/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 21:32:12 +0000</pubDate>
		<dc:creator>Jack Wallen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tutorials Advanced]]></category>
		<category><![CDATA[Tutorials Basic]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[automated tasks]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[cron job]]></category>
		<category><![CDATA[crontab]]></category>
		<category><![CDATA[script automation]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://www.ghacks.net/?p=9823</guid>
		<description><![CDATA[Linux is one of the most flexible and useful operating systems available. One of the tools that places Linux at the top of the flexibility and usability scale is cron. The cron system allows you to automate tasks without the aid of third party software. But because few know how to use cron, it seems [...]]]></description>
			<content:encoded><![CDATA[<p>Linux is one of the most flexible and useful operating systems available. One of the tools that places Linux at the top of the flexibility and usability scale is cron. The cron system allows you to automate tasks without the aid of third party software. But because few know how to use cron, it seems too complex to bother with. Not so. The cron system is actually quite easy to use. Let&#8217;s take a look at cron.</p>
<p>The cron system works by reading various crontab files either found in a users&#8217; directory or within the <strong>/etc </strong>directory. These cron files can be edited with either the <em>crontab</em> command or by editing the various files within <strong>/etc</strong>. Only the root user can edit the <strong>/etc</strong> files because those files (found in the subdirectories <strong>/etc/cron.d, /etc/cron.daily, /etc/cron.hourly, /etc/cron.weekly, /etc/cron.monthly</strong>) are used for system services.  Instead of focusing on system services, I will illustrate how to automate the execution of a user-created bash script.</p>
<p><span id="more-9823"></span>This imaginary bash script will be called <em>myscript.sh</em>. This script will be housed in <strong>/home/jlwallen/ </strong>and will have executable permission (by way of <em>chmod u+x myscript.sh</em>).  What we want to do is automate the execution of this script so that it executes once per day at the same time every day (we&#8217;ll say 7am).</p>
<p>Before we get into editing with crontab we first need to chat about how cron views time.The cron system looks at time like this:</p>
<ul>
<li><em>Minute(0-59)</em></li>
<li><em>Hour (0-23)</em></li>
<li><em>Day of the month (1-31)</em></li>
<li><em>Month (1-12)</em></li>
<li><em>Day of the week (0-6 with Sunday being 0)</em></li>
</ul>
<p>The structure of cron time looks like this:</p>
<p>Minute Hour Day of month Month Day of the week</p>
<p>The trick for cron is that when you do not have an entry for a section you add an &#8220;*&#8221;. So the time entry for a cron job that should run at 7am every day of the week would look like:</p>
<p><em>0 7 * * * </em></p>
<p>That is not the complete cron entry, just the time portion. Now, on to editing with crontab.</p>
<p><strong>Crontab</strong></p>
<p>Users edit their cron entries with the <em>crontab</em> command. The crontab command has a few switches:</p>
<ul>
<li>e &#8211; Edit your crontab</li>
<li>l &#8211; List your crontab</li>
<li>r &#8211; Delete all crontab entries</li>
</ul>
<p>To add a new crontab entry enter the command <em>crontab -e</em> which will place you in the vi text editor with your user crontab file opened. If you&#8217;re not familiar with vi I&#8217;ll give you the crash course as we edit the crontab.</p>
<p>First click the &#8220;i&#8221; key to go into the insert mode. You can now add text. Enter the cron entry to run the myscript.sh every day at 7am. This entry will look like:</p>
<p>* 7 * * * ~/myscript.sh</p>
<p>Now hit the Esc key to get out of the insert mode. Once out of insert mode you need to write the file and quite crontab. To do this hit the &#8220;:&#8221; key followed by &#8220;wq&#8221; (for write and quite). Finish the job by hitting the Enter key.</p>
<p>You should see &#8220;crontab: installing new crontab&#8221; at your bash prompt.</p>
<p>Congratulations, you&#8217;ve just created your first cron job!</p>

	Tags: <a href="http://www.ghacks.net/tag/automated-tasks/" title="automated tasks" rel="tag">automated tasks</a>, <a href="http://www.ghacks.net/tag/cron/" title="cron" rel="tag">cron</a>, <a href="http://www.ghacks.net/tag/cron-job/" title="cron job" rel="tag">cron job</a>, <a href="http://www.ghacks.net/tag/crontab/" title="crontab" rel="tag">crontab</a>, <a href="http://www.ghacks.net/tag/linux/" title="Linux" rel="tag">Linux</a>, <a href="http://www.ghacks.net/tag/script-automation/" title="script automation" rel="tag">script automation</a>, <a href="http://www.ghacks.net/tag/vi/" title="vi" rel="tag">vi</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.ghacks.net/2009/01/12/backup-mysql-databases-in-linux-regularly/" title="Backup MySQL Databases In Linux Regularly (January 12, 2009)">Backup MySQL Databases In Linux Regularly</a> (11)</li>
	<li><a href="http://www.ghacks.net/2009/01/22/back-up-your-apache-web-directory-and-database-with-this-simple-script/" title="Back up your Apache web directory and database with this simple script (January 22, 2009)">Back up your Apache web directory and database with this simple script</a> (0)</li>
	<li><a href="http://www.ghacks.net/2008/02/07/yoggie-pico-personal-mobile-security-computer/" title="Yoggie PICO Personal Mobile Security Computer (February 7, 2008)">Yoggie PICO Personal Mobile Security Computer</a> (3)</li>
	<li><a href="http://www.ghacks.net/2009/10/30/with-ubuntu-9-10-arrives-wubi-9-10/" title="With Ubuntu 9.10 Arrives Wubi 9.10 (October 30, 2009)">With Ubuntu 9.10 Arrives Wubi 9.10</a> (2)</li>
	<li><a href="http://www.ghacks.net/2006/12/07/widgets-for-linux-superkaramba/" title="Widgets for Linux: SuperKaramba (December 7, 2006)">Widgets for Linux: SuperKaramba</a> (6)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.ghacks.net/2009/01/11/using-cron-to-automate-linux-tasks/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
