<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>cron &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/cron/</link>
	<description>Feed of posts on WordPress.com tagged "cron"</description>
	<pubDate>Sun, 06 Dec 2009 05:18:23 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Backup στο Ubuntu με το "Back in Time"]]></title>
<link>http://ubuntugreek.wordpress.com/2009/11/25/backup-%cf%83%cf%84%ce%bf-ubuntu-%ce%bc%ce%b5-%cf%84%ce%bf-back-in-time/</link>
<pubDate>Wed, 25 Nov 2009 19:35:07 +0000</pubDate>
<dc:creator>xqtr</dc:creator>
<guid>http://ubuntugreek.wordpress.com/2009/11/25/backup-%cf%83%cf%84%ce%bf-ubuntu-%ce%bc%ce%b5-%cf%84%ce%bf-back-in-time/</guid>
<description><![CDATA[Μια φοβερη εφαρμογη για backup στο ubuntu, ειναι το &#8220;Back in time&#8221;. Αν εχετε επαφη με Ma]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><span style="font-size:x-large;"><strong>Μ</strong></span>ια φοβερη εφαρμογη για backup στο ubuntu, ειναι το &#8220;Back in time&#8221;. Αν εχετε επαφη με Mac ισως εχετε ακουστα το πολυ καλο, Time Machine. Και τα δυο προγραμματα δουλευουν με τον περιπου ιδιο τροπο. Ρυθμιζεται ποιους φακελους και αρχεια θελετε να κανετε backup, που να σωθει το backup και τη συχνοτητα που θελετε να περνετε τα backups.</p>
<p>Πολυ απλο στην λειτουργια του και ελαφρυ για τον υπολογιστη. Χρησιμοποιει τον cron για να περνει τα backups στα καθορισμενα χρονικα διαστηματα και ουτε που θα καταλαβετε οτι δουλευει στο background. Για να το εγκαταστησετε:</p>
<p><code>sudo apt-get install backintime-gnome</code></p>
<p>Δειτε και το παρακατω video:</p>
<p><code>http://www.youtube.com/watch?v=hcnNzrta7Jc</code></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Quickie HowTo - Cron Jobs Under FreeBSD]]></title>
<link>http://jasonk2600.wordpress.com/2009/11/24/quickie-howto-cron-jobs-under-freebsd/</link>
<pubDate>Tue, 24 Nov 2009 00:19:00 +0000</pubDate>
<dc:creator>jasonk2600</dc:creator>
<guid>http://jasonk2600.wordpress.com/2009/11/24/quickie-howto-cron-jobs-under-freebsd/</guid>
<description><![CDATA[Cron is a simple, but powerful utility used to automate repetitive tasks that do not require any use]]></description>
<content:encoded><![CDATA[Cron is a simple, but powerful utility used to automate repetitive tasks that do not require any use]]></content:encoded>
</item>
<item>
<title><![CDATA[Redmine Database Backup to S3, Periodically]]></title>
<link>http://cloudbuzz.wordpress.com/2009/11/23/redmine-database-backup-to-s3-periodically/</link>
<pubDate>Mon, 23 Nov 2009 10:01:44 +0000</pubDate>
<dc:creator>samof76</dc:creator>
<guid>http://cloudbuzz.wordpress.com/2009/11/23/redmine-database-backup-to-s3-periodically/</guid>
<description><![CDATA[Someone somewhere has alreaddy done this. But its fun doing it your way and more fun when you blog(b]]></description>
<content:encoded><![CDATA[Someone somewhere has alreaddy done this. But its fun doing it your way and more fun when you blog(b]]></content:encoded>
</item>
<item>
<title><![CDATA[Hello everyone. This is my first post he...]]></title>
<link>http://wpvideo.wordpress.com/2009/11/21/hello-everyone-this-is-my-first-post-he/</link>
<pubDate>Sat, 21 Nov 2009 18:05:24 +0000</pubDate>
<dc:creator>jimisaacs</dc:creator>
<guid>http://wpvideo.wordpress.com/2009/11/21/hello-everyone-this-is-my-first-post-he/</guid>
<description><![CDATA[Hello everyone. This is my first post here, and I&#8217;m looking for some guidance so I may give so]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Hello everyone. This is my first post here, and I&#8217;m looking for some guidance so I may give some guidance of my own hopefully.</p>
<p>I am on a RHEL server running the latest version but highly modified version of Scientific Linux.<br />
I have install all the necessary packages to run ffmpeg and qt-faststart.<br />
I run the video-verify-ffmpeg.php script and it runs successfully, I get the final message Congratulations! ffmpeg is installed correctly.<br />
I even run the ffmpeg command on multiple files to test outside of php, and it all runs smoothly so from what I can see the transcoder is fine.<br />
As for WPMU, I have it installed on the same server, and I have setup the table correctly, copied all the necessary files, and checked and rechecked my path environments.<br />
What happens is that when I upload a video through the backend. I get a message saying:<br />
&#8220;This video is being processed<br />
It will be ready in about 5 hours.&#8221;</p>
<p>Now this whole framework is new to me, so I was thinking this is quite a long time so I let it run overnight. I come back the next day and it says: &#8220;Video will be ready in a few minutes&#8221;. Clearly something was wrong, it had been over 12 hours.<br />
I tried again with various file types and sizes, all the same thing, an eta of about 5 hours, then it never finishes.</p>
<p>I figured it has to do with something with cron jobs. I haven&#8217;t ran any on this server, and was wondering if I may be missing to other packages I am unaware of.</p>
<p>Here is a link to my staging server to a post after I uploaded the same file the verify script uses, &#8220;baby.wmv&#8221;.</p>
<p>The time does seem to decrease, but it never finishes so please don&#8217;t bother to wait or anything. I really don&#8217;t know where to start debugging this, if anyone has a direction, I&#8217;m all ears.</p>
<p>Thanks.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[November 20th, 2009]]></title>
<link>http://faylinameir.wordpress.com/2009/11/20/november-20th-2009/</link>
<pubDate>Sat, 21 Nov 2009 05:34:50 +0000</pubDate>
<dc:creator>faylinameir</dc:creator>
<guid>http://faylinameir.wordpress.com/2009/11/20/november-20th-2009/</guid>
<description><![CDATA[Today was a bit more complex then yesterday and I was feeling lazy so I caved in and had some faux m]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Today was a bit more complex then yesterday and I was feeling lazy so I caved in and had some faux meat products.</p>
<p>I Had:<br />
40g Raisins<br />
2 small granny smith apples w/ skin<br />
12fl oz coffee w/ 2 Tbsp hazelnut silk creamer<br />
1 MorningStar Riblet<br />
2.5 small red potatoes mashed w/ &#8220;mayo&#8221;, dijon mustard, tofutti sour cream, fake bacon bits (all those in very small amounts)<br />
1 big can of creamed corn (I was being lazy)<br />
3/4 cup cooked brown rice lg<br />
12fl oz Almond Breeze</p>
<p>Here is how it came out:<br />
(Click to see full image)</p>
<p>&#160;</p>
<div class="mceTemp">
<dl class="wp-caption alignnone">
<dt class="wp-caption-dt"><a href="http://faylinameir.wordpress.com/files/2009/11/11-20-2009cron.png"><img class="size-thumbnail wp-image-13" title="11-20-2009cron" src="http://faylinameir.wordpress.com/files/2009/11/11-20-2009cron.png?w=150" alt="Nov.20th2009 Cron" width="150" height="67" /></a></dt>
</dl>
</div>
<p>&#160;</p>
<div class="mceTemp">
<dl class="wp-caption alignnone">
<dt class="wp-caption-dt"><a href="http://faylinameir.wordpress.com/files/2009/11/11-20-2009cronvm.png"><img class="size-thumbnail wp-image-14" title="11-20-2009cronvm" src="http://faylinameir.wordpress.com/files/2009/11/11-20-2009cronvm.png?w=150" alt="Nov.20th2009 Cron Vitamins/Minerals" width="150" height="116" /></a></dt>
</dl>
</div>
<p>_________</p>
<p>I feel so so today. I had a lazy start to my day and my head hurts.  My ratio was 9/82/9 which I think is a better ratio; yes a lot of it came from nonfresh fruits/veggies, but I&#8217;m kinda out of supplies so I&#8217;m making due til next month. I&#8217;m on a budget!  Oh.. ps&#8230; its still cold here!! I guess its winter so it could be worse.</p>
<p>&#160;</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[November 19th, 2009]]></title>
<link>http://faylinameir.wordpress.com/2009/11/20/november-19th-2009/</link>
<pubDate>Fri, 20 Nov 2009 12:16:26 +0000</pubDate>
<dc:creator>faylinameir</dc:creator>
<guid>http://faylinameir.wordpress.com/2009/11/20/november-19th-2009/</guid>
<description><![CDATA[So today was pretty small and simple. Maybe I should do this more often, who knows. I had: 20fl oz c]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>So today was pretty small and simple. Maybe I should do this more often, who knows.</p>
<p>I had:<br />
20fl oz cranberry juice<br />
1/3 cup. pomelo<br />
1/3 of my leftover homemade pizza<br />
two small granny smith apples<br />
3 Tablespoons of raisins, seeded<br />
12fl oz chocolate almond milk</p>
<p>Here is how the counts broke out to:</p>
<p><a href="http://faylinameir.wordpress.com/files/2009/11/11-19-2009cron.png"><img class="alignnone size-thumbnail wp-image-6" title="11-19-2009cron" src="http://faylinameir.wordpress.com/files/2009/11/11-19-2009cron.png?w=150" alt="Nov.19-2009 Cron-o-meter" width="150" height="71" /></a><br />
<a href="http://faylinameir.wordpress.com/files/2009/11/11-19-2009cronvm.png"><img class="alignnone size-thumbnail wp-image-10" title="11-19-2009cronvm" src="http://faylinameir.wordpress.com/files/2009/11/11-19-2009cronvm.png?w=150" alt="nov19-2009 vitamins and minerals" width="150" height="123" /></a></p>
<p>&#8212;&#8211;</p>
<p>Overall I felt good today, I was sluggish because I did oversleep a little. My meals were simple and that was okay. Maybe I should do it more often, I dunno. My back is really hurting today so I couldn&#8217;t even consider a form of exercise, and I&#8217;ve chosen not to weigh myself today. Or do anything any measurements. I was also in a good mood today. My only complaint would be its too cold here.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Routertech-Avviare auto_defragenv.sh ad intervalli regolari]]></title>
<link>http://gorneman.wordpress.com/2009/11/18/routertech-avviare-auto_defragenv-sh-ad-intervalli-regolari/</link>
<pubDate>Wed, 18 Nov 2009 17:58:46 +0000</pubDate>
<dc:creator>gorneman</dc:creator>
<guid>http://gorneman.wordpress.com/2009/11/18/routertech-avviare-auto_defragenv-sh-ad-intervalli-regolari/</guid>
<description><![CDATA[Come detto in un post precedente (questo), il bootloader ADAM2 che trovate su molti modem/router (fr]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Come detto in un post precedente (<a href="http://gorneman.wordpress.com/2009/09/28/uscito-firmware-routertech-2-91-1/">questo</a>), il <a href="http://www.hwupgrade.it/forum/showthread.php?p=22260843">bootloader ADAM2</a> che trovate su molti modem/router (fra i quali Dlink )  è soggetto ad una frequente &#8220;deframmentazione&#8221; della env, cioè della partizione (mtd3) contenente le variabili di sistema, e questo problema può portare il modem/router in &#8220;stallo&#8221;.</p>
<p>Per porre rimedio a questo problema il <a href="http://www.routertech.org/">team routertech</a> ha approntato nell&#8217;ultima versione del firmware (2.91.1) lo script &#8220;<a href="http://www.routertech.org/viewtopic.php?f=23&#38;t=2988">auto_defragenv.sh</a>&#8221; che controlla il livello di deframmentazione rispetto ad un valore di soglia (di default 30) e se superiore, deframmenta la env.</p>
<p>Lo script va avviato a mano (usando la schermata &#8220;Run Command&#8221;), oppure si può settare cron in modo che avvii il controllo ad intervalli regolari.</p>
<p>Nel mio caso ho scelto di far eseguire il controllo ogni domenica alle 23.30, ed ho impostato il tutto eseguendo il comando:</p>
<p>cronjob-env.sh &#8220;auto_defragenv.sh&#38;&#8221; &#8220;30&#8243; &#8220;23&#8243; &#8220;*&#8221; &#8220;*&#8221; &#8220;0&#8243; &#8220;RT_cmd_2&#8243;</p>
<p>cronjob-env.sh crea un nuovo job nella crontab ed inoltre &#8220;associa&#8221; una variabile a questo nella env, nel mio caso ho dato il nome &#8220;RT_cmd_2&#8243;: in questo modo anche in caso di riavvii, l&#8217;impostazione rimane memorizzata.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Linux Cron Job Tutorial: running a .php file]]></title>
<link>http://jadendreamer.wordpress.com/2009/11/17/linux-cron-job-tutorial-running-a-php-file/</link>
<pubDate>Tue, 17 Nov 2009 21:23:45 +0000</pubDate>
<dc:creator>Jade</dc:creator>
<guid>http://jadendreamer.wordpress.com/2009/11/17/linux-cron-job-tutorial-running-a-php-file/</guid>
<description><![CDATA[All of my database driven games use PHP as a scripting language which is my favorite scripting langu]]></description>
<content:encoded><![CDATA[All of my database driven games use PHP as a scripting language which is my favorite scripting langu]]></content:encoded>
</item>
<item>
<title><![CDATA[Episode 9: Using the Cron Service to run scheduled tasks]]></title>
<link>http://gaejexperiments.wordpress.com/2009/11/16/episode-9-using-the-cron-service-to-run-scheduled-tasks/</link>
<pubDate>Mon, 16 Nov 2009 16:34:02 +0000</pubDate>
<dc:creator>rominirani</dc:creator>
<guid>http://gaejexperiments.wordpress.com/2009/11/16/episode-9-using-the-cron-service-to-run-scheduled-tasks/</guid>
<description><![CDATA[Welcome to Episode 9. In this episode, we shall be looking at how you can run background tasks in yo]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Welcome to <strong>Episode 9</strong>. In this episode, we shall be looking at how you can run background tasks in your GAEJ Application. By background Task, I mean any piece of code that you would like to run at a scheduled time and independent of the user interaction.There are several examples of such tasks. For e.g. :</p>
<ul>
<li>Hourly/Daily/Weekly/Monthly backup of data</li>
<li>End of the day report generation to report any errors, transactions, etc.</li>
<li>Sending an email at the end of the day (or once a day) with some information to subscribers. For e.g. News sites.</li>
</ul>
<p>If you have written a few web applications, you would definitely have come across more scenarios like that.</p>
<p>In this episode, we shall cover the following:</p>
<ol>
<li>What is a Cron Job?</li>
<li>How to schedule a Cron Job?</li>
<li>Write a simple Cron Job that prints a single statement</li>
<li>Configure, execute and monitor the Cron Job execution</li>
</ol>
<p>Let&#8217;s go!</p>
<h2>What is a Cron Job? When would you need one?</h2>
<p>I will use information liberally from Wikipedia over here to explain some of the core concepts. You can refer to the <a href="http://en.wikipedia.org/wiki/Cron" target="_blank">Cron page</a> at Wikipedia if you want.</p>
<p>The word &#8216;cron&#8217; is short for Chronograph. A Cron is a time-based job scheduler. It enables our application to <strong>schedule</strong> a job to run automatically at a certain time or date. A Job (also known as a Task) is any module that you wish to run. This module can perform system maintenance or administration, though its general purpose nature means that it can be used for other purposes, such as connecting to the Internet and downloading email.</p>
<p>Examples include:</p>
<ul>
<li>Taking a daily backup of data via a scheduled task and moving the file to another server. (Runs once daily)</li>
<li>Sending an email every week to your subscribers. (Runs once weekly)</li>
<li>Clearing the log files at the end of every day (Runs once daily)</li>
<li>Remind yourself of a wonderful weekend coming up, every Friday at 5:00 PM (Runs once a week on a Friday at 5:00 PM)</li>
</ul>
<p>The Google App Engine provides a service called the <strong><a href="http://code.google.com/appengine/docs/java/config/cron.html" target="_blank">Cron Service</a></strong> that helps us do two fundamental things:</p>
<ol>
<li>Allows your application to schedule these tasks.</li>
<li>Execute these tasks based on their schedule.</li>
</ol>
<h2>What does a Cron Job look like? And how do I schedule one?</h2>
<p>A Cron Job is nothing but a <strong>URL</strong> that is invoked by the Google App Engine infrastructure at its scheduled execution time. To write a Cron Job, you need to do the following:</p>
<p>1. Write a <strong>Java Servlet</strong> and configure it in the <strong>web.xml</strong>. Note down the <strong>URL</strong> where the servlet can be invoked. The URL is the <strong>&#60;url-pattern&#62;</strong> mentioned in the <strong>&#60;servlet-mapping&#62;</strong> for your Servlet configuration in web.xml. For e.g.  the URL is the &#60;url-pattern&#62; element specified in the segment of the web.xml that is shown below:</p>
<pre class="brush: xml;">
&#60;servlet&#62;
 &#60;servlet-name&#62;GAEJCronServlet&#60;/servlet-name&#62;
 &#60;servlet-class&#62;com.gaejexperiments.cron.GAEJCronServlet&#60;/servlet-class&#62;
 &#60;/servlet&#62;

&#60;servlet-mapping&#62;
 &#60;servlet-name&#62;GAEJCronServlet&#60;/servlet-name&#62;
 &#60;url-pattern&#62;/cron/mycronjob&#60;/url-pattern&#62;
 &#60;/servlet-mapping&#62;
</pre>
<p>2. Create a <strong>cron.xml</strong> file that specifies one or more Cron Jobs (Scheduled Tasks) that you want to execute. A sample for the above Cron Job is shown below:</p>
<pre class="brush: xml;">
&#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62;
&#60;cronentries&#62;
 &#60;cron&#62;
 &#60;url&#62;/cron/mycronjob&#60;/url&#62;
 &#60;description&#62;Put your Cron Job description here&#60;/description&#62;
 &#60;schedule&#62;Put Cron Job Schedule here&#60;/schedule&#62;
 &#60;/cron&#62;
&#60;/cronentries&#62;
</pre>
<p>The <strong>cron.xml</strong> file tells Google App Engine about the Cron Jobs that are scheduled by your application. This file resides in the <strong>WEB-INF</strong> directory of your application and is copied to the App Engine cloud when you deploy the application. The following points are important about the <strong>cron.xml</strong> file:</p>
<ol>
<li>Each Cron Job configured in your application is defined in a <strong>&#60;cron/&#62;</strong> element. So there can be one or more <strong>&#60;cron/&#62;</strong> elements.</li>
<li>The above <strong>&#60;cron/&#62;</strong> element has the following 3 elements that defines the Job.
<ul>
<li><strong>&#60;url/&#62;</strong> specifies where the Google App Engine can invoke your Cron Job. This is nothing but the <strong>Servlet URL</strong> that you defined in the <strong>web.xml</strong> file that we saw earlier.The Servlet URL will point to your Servlet which contains the Cron Job implementation.</li>
<li><strong>&#60;description/&#62;</strong> is a simple text based description of what your Cron Job does. It does not influence any aspect of the execution and is used for display purposes when you look at your application configuration via the App Console.</li>
<li><strong>&#60;schedule/&#62;</strong> is the time when your Job has to be executed. This is where you specify if your job is to be run daily, once every hour, on Friday at 5:00 PM, etc. It is completely dependent on when you wish to execute this job. However, you must follow some rules and they are specified in the documentation on <strong><a href="http://code.google.com/appengine/docs/java/config/cron.html#The_Schedule_Format" target="_blank">Scheduling Format</a></strong>. I <strong>strongly</strong> recommend you to read it up to understand various ways of specifying the schedule. Some of the examples are: &#8220;every 1 minute&#8221;, &#8220;every 12 hours&#8221;, &#8220;every friday 17:00&#8243; and so on.</li>
</ul>
</li>
</ol>
<h2>Develop a simple Cron Job</h2>
<p>The first thing to do is to create a <strong>New Google Web Application</strong> Project. Follow these steps:</p>
<p>1. Either click on <strong>File –&#62; New –&#62; Other</strong> or <strong>press Ctrl-N</strong> to create a new project. Select Google and then Web Application project. Alternately you could also click on the New Web Application Project Toolbar icon as part of the Google Eclipse plugin.</p>
<p>2. In the New Web Application Project dialog, <strong>deselect the Use Google Web Toolkit</strong> and give a name to your project. I have named mine <strong>GAEJExperiments</strong>. I suggest you go with the same name so that things are consistent with the rest of the article, but I leave that to you. <strong>In case you are following the series, you could simply use the same project and skip all these steps altogether. You can simply go to the next part i.e. the Servlet code.</strong></p>
<p>3. Click on Finish. This will generate the project and also create a sample Hello World Servlet for you. But we will be writing our own Servlet.</p>
<h3>GAEJCronServlet.java</h3>
<p>Our Cron Job is going to be very simple. It is simply going to print out a statement in the log file that says that it is getting executed. The Cron Service of Google App Engine automatically will invoke this Servlet when its scheduled time to execute has arrived. So all we need to do is code out Servlet. The code is shown below:</p>
<pre class="brush: java;">
package com.gaejexperiments.cron;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.*;

@SuppressWarnings(&#34;serial&#34;)
public class GAEJCronServlet extends HttpServlet {
 private static final Logger _logger = Logger.getLogger(GAEJCronServlet.class.getName());
 public void doGet(HttpServletRequest req, HttpServletResponse resp)
 throws IOException {

 try {
 _logger.info(&#34;Cron Job has been executed&#34;);

 //Put your logic here
 //BEGIN
 //END
 }
 catch (Exception ex) {
 //Log any exceptions in your Cron Job
 }
 }

 @Override
 public void doPost(HttpServletRequest req, HttpServletResponse resp)
 throws ServletException, IOException {
 doGet(req, resp);
 }
}
</pre>
<p>The code is straightforward to understand. It has <strong>doGet()</strong> and <strong>doPost()</strong> methods. And you will find in the <strong>doGet()</strong> method, that we simply log with an INFO level, that the Cron Job has been executed. In fact, your actual Job implementation should go in here as indicated by the comments. So whether you are invoking a backend database, or sending a consolidated email report, etc should all go in here.</p>
<p>All that remains is to now tell the App Engine via configuration about your Servlet (<strong>via web.xml</strong>) and create the <strong>cron.xml</strong> file in which you will mention your Cron Job.</p>
<h2>Configure the Cron Job</h2>
<p>As mentioned, we need to configure the Servlet in the <strong>web.xml</strong> and also specify it in the <strong>cron.xml</strong> file. Let us look at that now:</p>
<h3>Configuring the Servlet</h3>
<p>We need to add the <strong>&#60;servlet/&#62;</strong> and <strong>&#60;servlet-mapping/&#62;</strong> entry to the <strong>web.xml</strong> file. This file is present in the <strong>WEB-INF</strong> folder of the project. The necessary fragment to be added to your <strong>web.xml</strong> file are shown below. Please note that you can use your own namespace and servlet class. Just modify it accordingly if you do so.</p>
<pre class="brush: xml;">
 &#60;servlet&#62;
   &#60;servlet-name&#62;GAEJCronServlet&#60;/servlet-name&#62;
   &#60;servlet-class&#62;com.gaejexperiments.cron.GAEJCronServlet&#60;/servlet-class&#62;
 &#60;/servlet&#62;

 &#60;servlet-mapping&#62;
   &#60;servlet-name&#62;GAEJCronServlet&#60;/servlet-name&#62;
   &#60;url-pattern&#62;/cron/gaejcronjob&#60;/url-pattern&#62;
 &#60;/servlet-mapping&#62;
</pre>
<h3>Specifying the Cron Job (cron.xml)</h3>
<p>The <strong>cron.xml</strong> for our application will contain only one Cron Job. And here we specify the Servlet URL along with the schedule. Notice that I have chosen to execute this Cron job every 2 minutes. But you are free to experiment if you like with different <strong><a href="http://code.google.com/appengine/docs/java/config/cron.html#The_Schedule_Format" target="_blank">Schedule Formats</a></strong>. This files needs to be created in the <strong>WEB-INF</strong> folder of your project.</p>
<pre class="brush: xml;">
&#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62;
&#60;cronentries&#62;
 &#60;cron&#62;
 &#60;url&#62;/cron/gaejcronjob&#60;/url&#62;
 &#60;description&#62;GAEJExperiments Cron Job that simply announces that it got invoked.&#60;/description&#62;
 &#60;schedule&#62;every 2 minutes&#60;/schedule&#62;
 &#60;/cron&#62;
&#60;/cronentries&#62;
</pre>
<h2>Deploy the Application</h2>
<p>To deploy the application, follow these steps (they should be familiar to you now. I am assuming that you already have the Application ID with you):</p>
<ol>
<li>Click on the Deploy Icon in the Toolbar.</li>
<li>In the Deploy dialog, provide your Email and Password. Do not click on Deploy button yet.</li>
<li>Click on the <strong>App Engine Project settings</strong> link. This will lead you to a dialog, where you need to enter your Application ID [For e.g. my Application Identifier <strong>gaejexperiments</strong>]</li>
<li>Click on <strong>OK</strong>. You will be lead back to the previous screen, where you can click on the <strong>Deploy </strong>button. This will start deploying your application to the GAEJ cloud. You should see several messages in the Console window as the application is being deployed.</li>
<li>Finally, you should see the message “Deployment completed successfully”.</li>
</ol>
<p>We can now check if the Google App Engine got our Cron Job correctly configured and verify if it is getting executed at the schedule that we have configured it to.</p>
<h2>Monitoring the Cron Job</h2>
<p>You can use the App Engine console to verify if your Cron Job is executing well or not. To do that, perform the following steps:</p>
<ol>
<li>Go to <a href="http://appengine.google.com/" target="_blank">http://appengine.google.com</a> and log in with your account.</li>
<li>You will see a list of applications registered. Click on the application that you just deployed. In my case, it is <strong>gaejexperiments.</strong></li>
<li>When you click on a particular application, you will be taken to the <strong>Dashboard</strong> for that application, which contains a wealth of information around the requests, quotas, logs, versions, etc.</li>
<li>Verify that the Cron Jobs that you specified in the <strong>cron.xml</strong> have been configured successfully for the application by clicking <strong>Cron Jobs, </strong>visible under <strong>Main.</strong> For our application that we deployed, here is the screen shot from the App Engine console:<a href="http://gaejexperiments.wordpress.com/files/2009/11/ep9-1.png"><img class="alignleft size-full wp-image-194" title="ep9-1" src="http://gaejexperiments.wordpress.com/files/2009/11/ep9-1.png" alt="ep9-1" width="600" height="300" /></a></li>
</ol>
<p style="padding-left:30px;">You will notice that the Cron Job has not yet run as the console indicates. Every time that the job is executed, this column is updated with the last date time stamp that the Job executed along with its status. Since we have configured our Job to run every 2 minutes, I waited for 2 minutes and then the job executed itself and when I refreshed the Cron Jobs page, the status was updated as shown below:</p>
<p style="padding-left:30px;"><a href="http://gaejexperiments.wordpress.com/files/2009/11/ep9-2.png"><img class="alignleft size-full wp-image-195" title="ep9-2" src="http://gaejexperiments.wordpress.com/files/2009/11/ep9-2.png" alt="ep9-2" width="600" height="153" /></a></p>
<p style="padding-left:30px;">You can also click on the <strong>Logs</strong> link. This will display the application log. And all your application log statements that you code using the Logger class can be visible here. By default, the severity level is set at ERROR and we can change that to INFO and you should be able your log statements that had the log level of INFO. This was the log level at which we had logged the statement in our Java Servlet (Cron Job). Shown below is a screen shot of the log when the Cron Job was fired once.</p>
<p style="padding-left:30px;"><a href="http://gaejexperiments.wordpress.com/files/2009/11/ep9-3.png"><img class="alignleft size-full wp-image-193" title="ep9-3" src="http://gaejexperiments.wordpress.com/files/2009/11/ep9-3.png" alt="ep9-3" width="600" height="159" /></a></p>
<h2>Conclusion</h2>
<p>This concludes Episode 9 of this series in which you learn how to schedule tasks in your Google App Engine applications. These background tasks that can be scheduled at a certain time and which are executed by the Cron Service are an indispensable part of several web applications that are deployed today. If you ever wish to do repeated tasks in your application without any user intervention like sending emails, crawling web sites, taking database backups, etc, then writing a Cron Job and scheduling it for execution is a key feature that you can utilize while deploying your application to Google App Engine.</p>
<p>There is a lot more to Cron Jobs and I suggest to read up the <a href="http://code.google.com/appengine/docs/java/config/cron.html" target="_blank">documentation</a>.</p>
<p>Till the next episode, Happy Scheduling!</p>
<p><img style="border:medium none;position:absolute;z-index:2147483647;opacity:0.6;display:none;" src="image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADsElEQVR4nK2VTW9VVRSGn33OPgWpYLARbKWhQlCHTogoSkjEkQwclEQcNJEwlfgD/AM6NBo1xjhx5LyJ0cYEDHGkJqhtBGKUpm3SFii3vb2956wPB/t+9raEgSs52fuus89613rftdcNH8/c9q9++oe/Vzb5P+3McyNcfm2CcPj9af9w6gwjTwzvethx3Bx3x8xwd1wNM8dMcTNUHTfFLPnX6nVmZpeIYwf3cWD/PhbrvlPkblAzVFurKS6GmmGqqComaS+qmBoTI0Ncu3mXuGvWnrJ+ZSxweDgnkHf8ndVTdbiT3M7cQp2Z31dRTecHAfqydp4ejhwazh6Zezfnu98E1WIQwB3crEuJ2Y45PBTAQUVR9X4At66AppoEVO1Q8sgAOKJJjw6Am6OquDmvHskZ3R87gW+vlHz98zpmiqphkkRVbQtsfPTOC30lJKFbFTgp83bWh7Zx/uX1B6w3hI3NkkZTqEpBRDBRzG2AQHcwcYwEkOGkTERREbLQ/8HxJwuW7zdYrzfZ2iopy4qqEspKaDYravVm33k1R91Q69FA1VBRzFIVvXbx5AgXT44A8MWP81yfu0utIR2aVK3vfCnGrcUNxp8a7gKYKiLCvY2SUvo/aNtnM3e49ucK9S3p0aDdaT0UAVsKi2tVi6IWwNL9JvdqTdihaz79/l+u/rHMxmaJVMLkS2OoKKLWacdeE3IsSxctc2D5Qcl6vUlVVgNt+fkPPcFFmTw1xruvT7SCd7nuVhDQvECzJH90h0azRKoKFRkAmP5lKTWAGRdefoZL554FQNUxB92WvYeA5UN4PtSqwB2phKqsqMpBgAunRhFR3j49zuU3jnX8k6fHEQKXzh1jbmGDuYU6s4t1rt6socUeLLZHhYO2AHSHmzt19ihTZ48O8Hzl/AmunD/BjTvrvPfNX3hWsNpwJCvwYm+ngug4UilSCSq6k8YPtxDwfA+WRawIWFbgscDiULcCEaWqBFOlrLazurupOSHLqGnEKJAY8TwBEHumqUirAjNm52vEPPRV4p01XXMPAQhUBjcWm9QZwijwokgAeYHlHYA06KR1cT6ZvoV56pDUJQEjw0KeaMgj1hPEY4vz2A4eW0/e1qA7KtQdsxTYAG0H3iG4xyK1Y+xm7XmEPOJZDiENzLi2WZHngeOjj2Pe+sMg4GRYyLAsx7ME4FnsyTD9pr0PEc8zPGRAwKXBkYOPEd96cZRvf11g9MDe7e3R4Z4Q+vyEnn3P4t0XzK/W+ODN5/kPfRLewAJVEQ0AAAAASUVORK5CYII%3D" alt="" width="24" height="24" /></p>
<p><img style="border:medium none;position:absolute;z-index:2147483647;opacity:0.6;display:none;" src="image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADsElEQVR4nK2VTW9VVRSGn33OPgWpYLARbKWhQlCHTogoSkjEkQwclEQcNJEwlfgD/AM6NBo1xjhx5LyJ0cYEDHGkJqhtBGKUpm3SFii3vb2956wPB/t+9raEgSs52fuus89613rftdcNH8/c9q9++oe/Vzb5P+3McyNcfm2CcPj9af9w6gwjTwzvethx3Bx3x8xwd1wNM8dMcTNUHTfFLPnX6nVmZpeIYwf3cWD/PhbrvlPkblAzVFurKS6GmmGqqComaS+qmBoTI0Ncu3mXuGvWnrJ+ZSxweDgnkHf8ndVTdbiT3M7cQp2Z31dRTecHAfqydp4ejhwazh6Zezfnu98E1WIQwB3crEuJ2Y45PBTAQUVR9X4At66AppoEVO1Q8sgAOKJJjw6Am6OquDmvHskZ3R87gW+vlHz98zpmiqphkkRVbQtsfPTOC30lJKFbFTgp83bWh7Zx/uX1B6w3hI3NkkZTqEpBRDBRzG2AQHcwcYwEkOGkTERREbLQ/8HxJwuW7zdYrzfZ2iopy4qqEspKaDYravVm33k1R91Q69FA1VBRzFIVvXbx5AgXT44A8MWP81yfu0utIR2aVK3vfCnGrcUNxp8a7gKYKiLCvY2SUvo/aNtnM3e49ucK9S3p0aDdaT0UAVsKi2tVi6IWwNL9JvdqTdihaz79/l+u/rHMxmaJVMLkS2OoKKLWacdeE3IsSxctc2D5Qcl6vUlVVgNt+fkPPcFFmTw1xruvT7SCd7nuVhDQvECzJH90h0azRKoKFRkAmP5lKTWAGRdefoZL554FQNUxB92WvYeA5UN4PtSqwB2phKqsqMpBgAunRhFR3j49zuU3jnX8k6fHEQKXzh1jbmGDuYU6s4t1rt6socUeLLZHhYO2AHSHmzt19ihTZ48O8Hzl/AmunD/BjTvrvPfNX3hWsNpwJCvwYm+ngug4UilSCSq6k8YPtxDwfA+WRawIWFbgscDiULcCEaWqBFOlrLazurupOSHLqGnEKJAY8TwBEHumqUirAjNm52vEPPRV4p01XXMPAQhUBjcWm9QZwijwokgAeYHlHYA06KR1cT6ZvoV56pDUJQEjw0KeaMgj1hPEY4vz2A4eW0/e1qA7KtQdsxTYAG0H3iG4xyK1Y+xm7XmEPOJZDiENzLi2WZHngeOjj2Pe+sMg4GRYyLAsx7ME4FnsyTD9pr0PEc8zPGRAwKXBkYOPEd96cZRvf11g9MDe7e3R4Z4Q+vyEnn3P4t0XzK/W+ODN5/kPfRLewAJVEQ0AAAAASUVORK5CYII%3D" alt="" width="24" height="24" /></p>
<p><img style="border:medium none;position:absolute;z-index:2147483647;opacity:0.6;display:none;" src="image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADsElEQVR4nK2VTW9VVRSGn33OPgWpYLARbKWhQlCHTogoSkjEkQwclEQcNJEwlfgD/AM6NBo1xjhx5LyJ0cYEDHGkJqhtBGKUpm3SFii3vb2956wPB/t+9raEgSs52fuus89613rftdcNH8/c9q9++oe/Vzb5P+3McyNcfm2CcPj9af9w6gwjTwzvethx3Bx3x8xwd1wNM8dMcTNUHTfFLPnX6nVmZpeIYwf3cWD/PhbrvlPkblAzVFurKS6GmmGqqComaS+qmBoTI0Ncu3mXuGvWnrJ+ZSxweDgnkHf8ndVTdbiT3M7cQp2Z31dRTecHAfqydp4ejhwazh6Zezfnu98E1WIQwB3crEuJ2Y45PBTAQUVR9X4At66AppoEVO1Q8sgAOKJJjw6Am6OquDmvHskZ3R87gW+vlHz98zpmiqphkkRVbQtsfPTOC30lJKFbFTgp83bWh7Zx/uX1B6w3hI3NkkZTqEpBRDBRzG2AQHcwcYwEkOGkTERREbLQ/8HxJwuW7zdYrzfZ2iopy4qqEspKaDYravVm33k1R91Q69FA1VBRzFIVvXbx5AgXT44A8MWP81yfu0utIR2aVK3vfCnGrcUNxp8a7gKYKiLCvY2SUvo/aNtnM3e49ucK9S3p0aDdaT0UAVsKi2tVi6IWwNL9JvdqTdihaz79/l+u/rHMxmaJVMLkS2OoKKLWacdeE3IsSxctc2D5Qcl6vUlVVgNt+fkPPcFFmTw1xruvT7SCd7nuVhDQvECzJH90h0azRKoKFRkAmP5lKTWAGRdefoZL554FQNUxB92WvYeA5UN4PtSqwB2phKqsqMpBgAunRhFR3j49zuU3jnX8k6fHEQKXzh1jbmGDuYU6s4t1rt6socUeLLZHhYO2AHSHmzt19ihTZ48O8Hzl/AmunD/BjTvrvPfNX3hWsNpwJCvwYm+ngug4UilSCSq6k8YPtxDwfA+WRawIWFbgscDiULcCEaWqBFOlrLazurupOSHLqGnEKJAY8TwBEHumqUirAjNm52vEPPRV4p01XXMPAQhUBjcWm9QZwijwokgAeYHlHYA06KR1cT6ZvoV56pDUJQEjw0KeaMgj1hPEY4vz2A4eW0/e1qA7KtQdsxTYAG0H3iG4xyK1Y+xm7XmEPOJZDiENzLi2WZHngeOjj2Pe+sMg4GRYyLAsx7ME4FnsyTD9pr0PEc8zPGRAwKXBkYOPEd96cZRvf11g9MDe7e3R4Z4Q+vyEnn3P4t0XzK/W+ODN5/kPfRLewAJVEQ0AAAAASUVORK5CYII%3D" alt="" width="24" height="24" /></p>
<p><img style="border:medium none;position:absolute;z-index:2147483647;opacity:0.6;display:none;" src="image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADsElEQVR4nK2VTW9VVRSGn33OPgWpYLARbKWhQlCHTogoSkjEkQwclEQcNJEwlfgD/AM6NBo1xjhx5LyJ0cYEDHGkJqhtBGKUpm3SFii3vb2956wPB/t+9raEgSs52fuus89613rftdcNH8/c9q9++oe/Vzb5P+3McyNcfm2CcPj9af9w6gwjTwzvethx3Bx3x8xwd1wNM8dMcTNUHTfFLPnX6nVmZpeIYwf3cWD/PhbrvlPkblAzVFurKS6GmmGqqComaS+qmBoTI0Ncu3mXuGvWnrJ+ZSxweDgnkHf8ndVTdbiT3M7cQp2Z31dRTecHAfqydp4ejhwazh6Zezfnu98E1WIQwB3crEuJ2Y45PBTAQUVR9X4At66AppoEVO1Q8sgAOKJJjw6Am6OquDmvHskZ3R87gW+vlHz98zpmiqphkkRVbQtsfPTOC30lJKFbFTgp83bWh7Zx/uX1B6w3hI3NkkZTqEpBRDBRzG2AQHcwcYwEkOGkTERREbLQ/8HxJwuW7zdYrzfZ2iopy4qqEspKaDYravVm33k1R91Q69FA1VBRzFIVvXbx5AgXT44A8MWP81yfu0utIR2aVK3vfCnGrcUNxp8a7gKYKiLCvY2SUvo/aNtnM3e49ucK9S3p0aDdaT0UAVsKi2tVi6IWwNL9JvdqTdihaz79/l+u/rHMxmaJVMLkS2OoKKLWacdeE3IsSxctc2D5Qcl6vUlVVgNt+fkPPcFFmTw1xruvT7SCd7nuVhDQvECzJH90h0azRKoKFRkAmP5lKTWAGRdefoZL554FQNUxB92WvYeA5UN4PtSqwB2phKqsqMpBgAunRhFR3j49zuU3jnX8k6fHEQKXzh1jbmGDuYU6s4t1rt6socUeLLZHhYO2AHSHmzt19ihTZ48O8Hzl/AmunD/BjTvrvPfNX3hWsNpwJCvwYm+ngug4UilSCSq6k8YPtxDwfA+WRawIWFbgscDiULcCEaWqBFOlrLazurupOSHLqGnEKJAY8TwBEHumqUirAjNm52vEPPRV4p01XXMPAQhUBjcWm9QZwijwokgAeYHlHYA06KR1cT6ZvoV56pDUJQEjw0KeaMgj1hPEY4vz2A4eW0/e1qA7KtQdsxTYAG0H3iG4xyK1Y+xm7XmEPOJZDiENzLi2WZHngeOjj2Pe+sMg4GRYyLAsx7ME4FnsyTD9pr0PEc8zPGRAwKXBkYOPEd96cZRvf11g9MDe7e3R4Z4Q+vyEnn3P4t0XzK/W+ODN5/kPfRLewAJVEQ0AAAAASUVORK5CYII%3D" alt="" width="24" height="24" /></p>
<p><img style="border:medium none;position:absolute;z-index:2147483647;opacity:0.6;display:none;" src="image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADsElEQVR4nK2VTW9VVRSGn33OPgWpYLARbKWhQlCHTogoSkjEkQwclEQcNJEwlfgD/AM6NBo1xjhx5LyJ0cYEDHGkJqhtBGKUpm3SFii3vb2956wPB/t+9raEgSs52fuus89613rftdcNH8/c9q9++oe/Vzb5P+3McyNcfm2CcPj9af9w6gwjTwzvethx3Bx3x8xwd1wNM8dMcTNUHTfFLPnX6nVmZpeIYwf3cWD/PhbrvlPkblAzVFurKS6GmmGqqComaS+qmBoTI0Ncu3mXuGvWnrJ+ZSxweDgnkHf8ndVTdbiT3M7cQp2Z31dRTecHAfqydp4ejhwazh6Zezfnu98E1WIQwB3crEuJ2Y45PBTAQUVR9X4At66AppoEVO1Q8sgAOKJJjw6Am6OquDmvHskZ3R87gW+vlHz98zpmiqphkkRVbQtsfPTOC30lJKFbFTgp83bWh7Zx/uX1B6w3hI3NkkZTqEpBRDBRzG2AQHcwcYwEkOGkTERREbLQ/8HxJwuW7zdYrzfZ2iopy4qqEspKaDYravVm33k1R91Q69FA1VBRzFIVvXbx5AgXT44A8MWP81yfu0utIR2aVK3vfCnGrcUNxp8a7gKYKiLCvY2SUvo/aNtnM3e49ucK9S3p0aDdaT0UAVsKi2tVi6IWwNL9JvdqTdihaz79/l+u/rHMxmaJVMLkS2OoKKLWacdeE3IsSxctc2D5Qcl6vUlVVgNt+fkPPcFFmTw1xruvT7SCd7nuVhDQvECzJH90h0azRKoKFRkAmP5lKTWAGRdefoZL554FQNUxB92WvYeA5UN4PtSqwB2phKqsqMpBgAunRhFR3j49zuU3jnX8k6fHEQKXzh1jbmGDuYU6s4t1rt6socUeLLZHhYO2AHSHmzt19ihTZ48O8Hzl/AmunD/BjTvrvPfNX3hWsNpwJCvwYm+ngug4UilSCSq6k8YPtxDwfA+WRawIWFbgscDiULcCEaWqBFOlrLazurupOSHLqGnEKJAY8TwBEHumqUirAjNm52vEPPRV4p01XXMPAQhUBjcWm9QZwijwokgAeYHlHYA06KR1cT6ZvoV56pDUJQEjw0KeaMgj1hPEY4vz2A4eW0/e1qA7KtQdsxTYAG0H3iG4xyK1Y+xm7XmEPOJZDiENzLi2WZHngeOjj2Pe+sMg4GRYyLAsx7ME4FnsyTD9pr0PEc8zPGRAwKXBkYOPEd96cZRvf11g9MDe7e3R4Z4Q+vyEnn3P4t0XzK/W+ODN5/kPfRLewAJVEQ0AAAAASUVORK5CYII%3D" alt="" width="24" height="24" /></p>
<p><img style="border:medium none;position:absolute;z-index:2147483647;opacity:0.6;display:none;" src="image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADsElEQVR4nK2VTW9VVRSGn33OPgWpYLARbKWhQlCHTogoSkjEkQwclEQcNJEwlfgD/AM6NBo1xjhx5LyJ0cYEDHGkJqhtBGKUpm3SFii3vb2956wPB/t+9raEgSs52fuus89613rftdcNH8/c9q9++oe/Vzb5P+3McyNcfm2CcPj9af9w6gwjTwzvethx3Bx3x8xwd1wNM8dMcTNUHTfFLPnX6nVmZpeIYwf3cWD/PhbrvlPkblAzVFurKS6GmmGqqComaS+qmBoTI0Ncu3mXuGvWnrJ+ZSxweDgnkHf8ndVTdbiT3M7cQp2Z31dRTecHAfqydp4ejhwazh6Zezfnu98E1WIQwB3crEuJ2Y45PBTAQUVR9X4At66AppoEVO1Q8sgAOKJJjw6Am6OquDmvHskZ3R87gW+vlHz98zpmiqphkkRVbQtsfPTOC30lJKFbFTgp83bWh7Zx/uX1B6w3hI3NkkZTqEpBRDBRzG2AQHcwcYwEkOGkTERREbLQ/8HxJwuW7zdYrzfZ2iopy4qqEspKaDYravVm33k1R91Q69FA1VBRzFIVvXbx5AgXT44A8MWP81yfu0utIR2aVK3vfCnGrcUNxp8a7gKYKiLCvY2SUvo/aNtnM3e49ucK9S3p0aDdaT0UAVsKi2tVi6IWwNL9JvdqTdihaz79/l+u/rHMxmaJVMLkS2OoKKLWacdeE3IsSxctc2D5Qcl6vUlVVgNt+fkPPcFFmTw1xruvT7SCd7nuVhDQvECzJH90h0azRKoKFRkAmP5lKTWAGRdefoZL554FQNUxB92WvYeA5UN4PtSqwB2phKqsqMpBgAunRhFR3j49zuU3jnX8k6fHEQKXzh1jbmGDuYU6s4t1rt6socUeLLZHhYO2AHSHmzt19ihTZ48O8Hzl/AmunD/BjTvrvPfNX3hWsNpwJCvwYm+ngug4UilSCSq6k8YPtxDwfA+WRawIWFbgscDiULcCEaWqBFOlrLazurupOSHLqGnEKJAY8TwBEHumqUirAjNm52vEPPRV4p01XXMPAQhUBjcWm9QZwijwokgAeYHlHYA06KR1cT6ZvoV56pDUJQEjw0KeaMgj1hPEY4vz2A4eW0/e1qA7KtQdsxTYAG0H3iG4xyK1Y+xm7XmEPOJZDiENzLi2WZHngeOjj2Pe+sMg4GRYyLAsx7ME4FnsyTD9pr0PEc8zPGRAwKXBkYOPEd96cZRvf11g9MDe7e3R4Z4Q+vyEnn3P4t0XzK/W+ODN5/kPfRLewAJVEQ0AAAAASUVORK5CYII%3D" alt="" width="24" height="24" /></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Automatically running sql_advisor tasks from ADDM reports]]></title>
<link>http://jhdba.wordpress.com/2009/11/12/automatically-running-sql_advisor-tasks-from-addm-reports/</link>
<pubDate>Thu, 12 Nov 2009 08:29:21 +0000</pubDate>
<dc:creator>John Hallas</dc:creator>
<guid>http://jhdba.wordpress.com/2009/11/12/automatically-running-sql_advisor-tasks-from-addm-reports/</guid>
<description><![CDATA[STOP PRESS &#8211; 17 Nov 2009  &#8211; updated with latest code which works against both 10g and 11]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><span style="color:#ff0000;"><strong>STOP PRESS &#8211; 17 Nov 2009  &#8211; updated with latest code which works against both 10g and 11g databases</strong></span></p>
<p> I am attaching scripts which I wrote a while ago to automatically pick any sql_ids reported in the latest ADDM and then run sql_advisor to report on any tuning advice. I am not suggesting that the information they provide is not available from EM or indeed every task reported needs resolving but it can be a good heads-up on a system you don&#8217;t know very well.</p>
<p>These are enabled every hour (can be less depending upon your snapshot interval) and they create a daily file which can be easily reviewed.</p>
<p>I find the real benefit is not on production databases but on dev and test databases that are being used for development prior to production implementation. This is for two reasons, firstly I hope that the team has a good handle on what is happening in production and are aware of issues and secondly we are most likely  to be able to add most value and benefit in development environments before the code is made live.</p>
<p>A couple of &#8216;issuettes&#8217;. The output from the ADDM report is different between 10g and 11g so I have amended the awk file to cater for both versions. I have been having an ongoing problem with tghe sql_advisor tuning task timing out on some systems and consequently leaving the task created for the next run. I have therefore amended the loop to drop the task at several points which looks untidy in the output file bit does seem to resolve the problem. </p>
<p>I hoped to attach a zip file containing 4 scripts but cannot see how to do it without a plug-in which is a problem on my works PC. so in the meantime I have pasted the code of each of 4 files.</p>
<p><strong>tuning_recommendations.ksh</strong> which is the controlling script</p>
<pre class="brush: plain;">#! /bin/ksh
# loop though the file produced from get_addm_report.sql and put the gathered sql-ids into a flat file
# awk the file to get just the SQL_ID
# for each sql_id create a task, execute that task, run the report and then delete the task
#
# The delete tuning task job is run an additional twice because if the tuning task times out then it does not clean up properly
# Better to see a few failures in this job that not run the sql_tuning_advisor at all.
#if [ -d /home/oracle/logs ]
then
   rm  /home/oracle/logs/tmp*.log
   else
   mkdir /home/oracle/logs
   exit
fi
if [ $# -ne 1 ]
then
    echo &#34;No ORACLE SID  - exiting&#34;
    exit
fi
# execute ORACLE's .profile
#
#. ~/.profile
unset ORAENV_ASK
#
# set up environment variables.
#

ORACLE_SID=$1
. /usr/local/bin/oraenv ${ORACLE_SID}
export ORACLE_HOME=`cat /etc/oratab &#124; grep $ORACLE_SID &#124; awk -F: '{print $2 }`
export PATH=$ORACLE_HOME/bin:$PATH
export ORAENV_ASK=NO
today=`date +%d-%b-%Y`; export today
LOGDIR=$HOME/logs
LOGFILE=$LOGDIR/get_addm_${today}.log
REPORTFILE=$LOGDIR/sql_advisor_report_${ORACLE_SID}_${today}.log

#
#
sqlplus -s /nolog  &#60;&#60;SQLEND
connect / as sysdba
     spool $LOGDIR/tmp_${ORACLE_SID}_1.log
     @/shared/oracle/performance/get_addm_report.sql
     spool off
     exit
SQLEND

&#60;p&#62;&#38;nbsp;&#60;/p&#62;

cat $LOGDIR/tmp_${ORACLE_SID}_1.log&#124;awk -f /shared/oracle/performance/tuning_recommendations.awk &#124;awk '!a[$0]++' &#62; $LOGDIR/tmp_${ORACLE_SID}_2.log
cat  $LOGDIR/tmp_${ORACLE_SID}_2.log &#124; awk '$0!~/^$/ {print $0}' &#62; $LOGDIR/tmp_${ORACLE_SID}_3.log

for PLAN in  `cat $LOGDIR/tmp_${ORACLE_SID}_3.log`
do
sqlplus -s /nolog  &#60;&#60;SQLEND &#62;&#62; $REPORTFILE
connect / as sysdba
        begin
        DBMS_SQLTUNE.drop_tuning_task('test_task1');
        end;
        /
     SELECT status FROM USER_ADVISOR_TASKS WHERE task_name = 'test_task1';
     @/shared/oracle/performance/sql_advisor.sql $PLAN
     exit
SQLEND
done

# tidy up the report file
# tidy up reports &#62; 14 days old
find  $LOGDIR -name &#34;sql_advisor_repor*.log&#34; -mtime +14 -print -exec rm -f {} \;
</pre>
</pre>
<p><strong>get_addm_report.sql </strong>which gets each task from the last snapshot from dba_advisor_tasks</p>
<pre class="brush: plain;">set long  10000000
set pagesize 50000
column get_clob format a80

select dbms_advisor.get_task_report (task_name) as ADDM_report
from dba_advisor_tasks
where task_id = (
        select max(t. task_id)
        from dba_advisor_tasks t, dba_advisor_log l
        where t.task_id = l.task_id
        and t.advisor_name = 'ADDM'
        and l.status = 'COMPLETED');
</pre>
<p><strong>tuning_recommendations.awk </strong>is a short awk script used to process the output from get_addm_report.sql</p>
<pre class="brush: plain;">BEGIN{
#start at the first line
#OUTFILE=&#34;$HOME/logs/outfile.log&#34;
}
{
        {
                if (($1==&#34;RATIONALE:&#34;) &#38;&#38; ($2==&#34;SQL&#34;)) #10G ADDM format
                {
                        F1=$6
                }
                if (($1==&#34;Run&#34;) &#38;&#38; ($2==&#34;SQL&#34;) &#38;&#38; ($3==&#34;Tuning&#34;) &#38;&#38; ($4==&#34;Advisor&#34;) &#38;&#38; ($7==&#34;SQL&#34;) &#38;&#38; ($10==&#34;SQL_ID&#34;)) #11G ADDM format
                {
                        F1=$11
                }

        }
VAR1=substr(F1,2,13)
print VAR1
}
END{
}
</pre>
<p><strong>sql_advisor.sql </strong>runs the sql_advisor package against each task found.</p>
<pre class="brush: plain;">DECLARE
my_task_name   VARCHAR2 (30);
my_sqltext     CLOB;
my_sqlid        varchar2(30);

BEGIN
my_sqlid := '&#38;1';
my_task_name := dbms_sqltune.create_tuning_task (sql_id=&#62; my_sqlid,
       scope         =&#62; 'COMPREHENSIVE',
       time_limit    =&#62; 300,
       task_name     =&#62; 'test_task1',
       description   =&#62; 'test_task1'
    );
END;
/

BEGIN
dbms_sqltune.execute_tuning_task (task_name =&#62; 'test_task1');
END;
/

SELECT status FROM USER_ADVISOR_TASKS WHERE task_name = 'test_task1';
SET LONG 10000
SET LONGCHUNKSIZE 10000
SET LINESIZE 100
set pages 60
SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK( 'test_task1')
FROM DUAL;
begin
DBMS_SQLTUNE.drop_tuning_task('test_task1');
end;
/
</pre>
<p>We have a read only NFS mounted disk available on all database servers and the files are placed in there and initiated by a cron entry for each SID on an hourly basis<br />
40 * * * * /shared/oracle/performance/tuning_recommendations.ksh SID &#62;/dev/null 2&#62;&#38;1</p>
<p>Output is created in a folder $HOME/logs and 14 days worth of reports are kept.</p>
<p>A sample output report (only one task shown but certainly on this Peoplesoft database it would show many tasks)</p>
<pre class="brush: plain;">DBMS_SQLTUNE.REPORT_TUNING_TASK('TEST_TASK1')
----------------------------------------------------------------------------------------------------
GENERAL INFORMATION SECTION
-------------------------------------------------------------------------------
Tuning Task Name                  : test_task1
Tuning Task Owner                 : SYS
Scope                             : COMPREHENSIVE
Time Limit(seconds)               : 60
Completion Status                 : COMPLETED
Started at                        : 11/12/2009 07:43:33
Completed at                      : 11/12/2009 07:44:16
Number of Statistic Findings      : 1
Number of Index Findings          : 1

-------------------------------------------------------------------------------
Schema Name: SYSADM
SQL ID     : cy3fmjha2sjnr
SQL Text   : SELECT M.EMPLID, M.EMPL_RCD, M.SCH_PRIM_ALT_IND,
             TO_CHAR(M.DUR,'YYYY-MM-DD'), M.SEQ_NO, M.CHNG_PRIMARY,
             M.SCHEDULE_GRP, M.SETID, M.WRKDAY_ID, M.SHIFT_ID, M.SCHED_HRS,
             M.SCH_CONFIG1, M.SCH_CONFIG2, M.SCH_CONFIG3, M.SCH_CONFIG4,
             TO_CHAR(M.START_DTTM,'YYYY-MM-DD-HH24.MI.SS.&#38;amp;quot;000000&#38;amp;quot;'),
             TO_CHAR(M.END_DTTM,'YYYY-MM-DD-HH24.MI.SS.&#38;amp;quot;000000&#38;amp;quot;'),
             M.SCHED_SOURCE, M.OFFDAY_IND, A.TIMEZONE, A.SCH_CATEGORY From
             PS_SCH_MNG_SCH_TBL M, PS_SCH_ADHOC_DTL A Where M.EMPLID = :1 and
             M.EMPL_RCD = :2 and M.SCH_PRIM_ALT_IND = :3 and M.DUR between
             TO_DATE(:4,'YYYY-MM-DD') and TO_DATE(:5,'YYYY-MM-DD') and
             A.EMPLID = M.EMPLID and A.EMPL_RCD = M.EMPL_RCD and
             A.SCH_PRIM_ALT_IND = M.SCH_PRIM_ALT_IND and A.DUR = M.DUR and
             A.SEQ_NO = M.SEQ_NO and A.SEQNUM = 1 Order By M.DUR Asc,
             M.SCHED_SOURCE Desc, M.SEQ_NO Desc

-------------------------------------------------------------------------------
FINDINGS SECTION (2 findings)
-------------------------------------------------------------------------------

1- Statistics Finding
---------------------
  Optimizer statistics for index &#38;amp;quot;SYSADM&#38;amp;quot;.&#38;amp;quot;PS_SCH_MNG_SCH_TBL&#38;amp;quot; are stale.

  Recommendation
  --------------
  - Consider collecting optimizer statistics for this index.
    execute dbms_stats.gather_index_stats(ownname =&#38;amp;gt; 'SYSADM', indname =&#38;amp;gt;
            'PS_SCH_MNG_SCH_TBL', estimate_percent =&#38;amp;gt;
            DBMS_STATS.AUTO_SAMPLE_SIZE);

  Rationale
  ---------
    The optimizer requires up-to-date statistics for the index in order to
    select a good execution plan.

2- Index Finding (see explain plans section below)
--------------------------------------------------
  The execution plan of this statement can be improved by creating one or more
  indices.

  Recommendation (estimated benefit: 94.67%)
  ------------------------------------------

DBMS_SQLTUNE.REPORT_TUNING_TASK('TEST_TASK1')
----------------------------------------------------------------------------------------------------
  - Consider running the Access Advisor to improve the physical schema design
    or creating the recommended index.
    create index SYSADM.IDX$$_21C0F0001 on
    SYSADM.PS_SCH_ADHOC_DTL(&#38;amp;quot;EMPLID&#38;amp;quot;,&#38;amp;quot;SEQNUM&#38;amp;quot;,&#38;amp;quot;EMPL_RCD&#38;amp;quot;,&#38;amp;quot;SCH_PRIM_ALT_IND&#38;amp;quot;,&#38;amp;quot;DU
    R&#38;amp;quot;);

  - Consider running the Access Advisor to improve the physical schema design
    or creating the recommended index.
    create index SYSADM.IDX$$_21C0F0002 on
    SYSADM.PS_SCH_MNG_SCH_TBL(&#38;amp;quot;EMPLID&#38;amp;quot;,&#38;amp;quot;DUR&#38;amp;quot;);

  Rationale
  ---------
    Creating the recommended indices significantly improves the execution plan
    of this statement. However, it might be preferable to run &#38;amp;quot;Access Advisor&#38;amp;quot;
    using a representative SQL workload as opposed to a single statement. This
    will allow to get comprehensive index recommendations which takes into
    account index maintenance overhead and additional space consumption.

-------------------------------------------------------------------------------
EXPLAIN PLANS SECTION
-------------------------------------------------------------------------------

1- Original
-----------
Plan hash value: 2070933151

----------------------------------------------------------------------------------------------------
------------------------
&#124; Id  &#124; Operation                             &#124; Name               &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Ti
me     &#124; Pstart&#124; Pstop &#124;
----------------------------------------------------------------------------------------------------
------------------------
&#124;   0 &#124; SELECT STATEMENT                      &#124;                    &#124;     1 &#124;   103 &#124;   387   (1)&#124; 00
:00:01 &#124;       &#124;       &#124;
&#124;*  1 &#124;  FILTER                               &#124;                    &#124;       &#124;       &#124;            &#124;
       &#124;       &#124;       &#124;
&#124;   2 &#124;   SORT ORDER BY                       &#124;                    &#124;     1 &#124;   103 &#124;   387   (1)&#124; 00
:00:01 &#124;       &#124;       &#124;
&#124;   3 &#124;    NESTED LOOPS                       &#124;                    &#124;     1 &#124;   103 &#124;   386   (1)&#124; 00
:00:01 &#124;       &#124;       &#124;
&#124;   4 &#124;     PARTITION RANGE ITERATOR          &#124;                    &#124;    10 &#124;   350 &#124;   371   (1)&#124; 00
:00:01 &#124;   KEY &#124;   KEY &#124;
&#124;   5 &#124;      TABLE ACCESS BY LOCAL INDEX ROWID&#124; PS_SCH_ADHOC_DTL   &#124;    10 &#124;   350 &#124;   371   (1)&#124; 00
:00:01 &#124;   KEY &#124;   KEY &#124;
&#124;*  6 &#124;       INDEX RANGE SCAN                &#124; PS_SCH_ADHOC_DTL   &#124;    10 &#124;       &#124;   369   (1)&#124; 00
:00:01 &#124;   KEY &#124;   KEY &#124;
&#124;   7 &#124;     PARTITION RANGE ITERATOR          &#124;                    &#124;     1 &#124;    68 &#124;     2   (0)&#124; 00
:00:01 &#124;   KEY &#124;   KEY &#124;
&#124;   8 &#124;      TABLE ACCESS BY LOCAL INDEX ROWID&#124; PS_SCH_MNG_SCH_TBL &#124;     1 &#124;    68 &#124;     2   (0)&#124; 00
:00:01 &#124;   KEY &#124;   KEY &#124;
&#124;*  9 &#124;       INDEX UNIQUE SCAN               &#124; PS_SCH_MNG_SCH_TBL &#124;     1 &#124;       &#124;     1   (0)&#124; 00
:00:01 &#124;   KEY &#124;   KEY &#124;
----------------------------------------------------------------------------------------------------
------------------------

Predicate Information (identified by operation id):

DBMS_SQLTUNE.REPORT_TUNING_TASK('TEST_TASK1')
----------------------------------------------------------------------------------------------------
---------------------------------------------------

   1 - filter(TO_DATE(:4,'YYYY-MM-DD')&#38;amp;lt;=TO_DATE(:5,'YYYY-MM-DD'))
   6 - access(&#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;EMPLID&#38;amp;quot;=:1 AND &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;EMPL_RCD&#38;amp;quot;=TO_NUMBER(:2) AND &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;SCH_PRIM_ALT_IND&#38;amp;quot;=:3 AND
              &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;DUR&#38;amp;quot;&#38;amp;gt;=TO_DATE(:4,'YYYY-MM-DD') AND &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;SEQNUM&#38;amp;quot;=1 AND &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;DUR&#38;amp;quot;&#38;amp;lt;=TO_DATE(:5,'YYYY
-MM-DD'))
       filter(&#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;SEQNUM&#38;amp;quot;=1)
   9 - access(&#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;EMPLID&#38;amp;quot;=:1 AND &#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;EMPL_RCD&#38;amp;quot;=TO_NUMBER(:2) AND &#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;SCH_PRIM_ALT_IND&#38;amp;quot;=:3 AND
              &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;DUR&#38;amp;quot;=&#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;DUR&#38;amp;quot; AND &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;SEQ_NO&#38;amp;quot;=&#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;SEQ_NO&#38;amp;quot;)
       filter(&#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;DUR&#38;amp;quot;&#38;amp;gt;=TO_DATE(:4,'YYYY-MM-DD') AND &#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;DUR&#38;amp;quot;&#38;amp;lt;=TO_DATE(:5,'YYYY-MM-DD'))

2- Using New Indices
--------------------
Plan hash value: 1209469329

----------------------------------------------------------------------------------------------------
------------------------
&#124; Id  &#124; Operation                             &#124; Name               &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Ti
me     &#124; Pstart&#124; Pstop &#124;
----------------------------------------------------------------------------------------------------
------------------------
&#124;   0 &#124; SELECT STATEMENT                      &#124;                    &#124;     1 &#124;   103 &#124;    21  (10)&#124; 00
:00:01 &#124;       &#124;       &#124;
&#124;*  1 &#124;  FILTER                               &#124;                    &#124;       &#124;       &#124;            &#124;
       &#124;       &#124;       &#124;
&#124;   2 &#124;   SORT ORDER BY                       &#124;                    &#124;     1 &#124;   103 &#124;    21  (10)&#124; 00
:00:01 &#124;       &#124;       &#124;
&#124;*  3 &#124;    HASH JOIN                          &#124;                    &#124;     1 &#124;   103 &#124;    20   (5)&#124; 00
:00:01 &#124;       &#124;       &#124;
&#124;   4 &#124;     TABLE ACCESS BY GLOBAL INDEX ROWID&#124; PS_SCH_ADHOC_DTL   &#124;    10 &#124;   350 &#124;    10   (0)&#124; 00
:00:01 &#124; ROWID &#124; ROWID &#124;
&#124;*  5 &#124;      INDEX RANGE SCAN                 &#124; IDX$$_21C0F0001    &#124;    10 &#124;       &#124;     4   (0)&#124; 00
:00:01 &#124;       &#124;       &#124;
&#124;*  6 &#124;     TABLE ACCESS BY GLOBAL INDEX ROWID&#124; PS_SCH_MNG_SCH_TBL &#124;    13 &#124;   884 &#124;     9   (0)&#124; 00
:00:01 &#124; ROWID &#124; ROWID &#124;
&#124;*  7 &#124;      INDEX RANGE SCAN                 &#124; IDX$$_21C0F0002    &#124;    13 &#124;       &#124;     3   (0)&#124; 00
:00:01 &#124;       &#124;       &#124;
----------------------------------------------------------------------------------------------------
------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter(TO_DATE(:4,'YYYY-MM-DD')&#38;amp;lt;=TO_DATE(:5,'YYYY-MM-DD'))
   3 - access(&#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;EMPLID&#38;amp;quot;=&#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;EMPLID&#38;amp;quot; AND &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;EMPL_RCD&#38;amp;quot;=&#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;EMPL_RCD&#38;amp;quot; AND
              &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;SCH_PRIM_ALT_IND&#38;amp;quot;=&#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;SCH_PRIM_ALT_IND&#38;amp;quot; AND &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;DUR&#38;amp;quot;=&#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;DUR&#38;amp;quot; AND
              SYS_OP_DESCEND(&#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;DUR&#38;amp;quot;)=SYS_OP_DESCEND(&#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;DUR&#38;amp;quot;) AND &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;SEQ_NO&#38;amp;quot;=&#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;SEQ_NO&#38;amp;quot;)
   5 - access(&#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;EMPLID&#38;amp;quot;=:1 AND &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;SEQNUM&#38;amp;quot;=1 AND &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;EMPL_RCD&#38;amp;quot;=TO_NUMBER(:2) AND &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;SCH_PRIM_
ALT_IND&#38;amp;quot;=:3 AND
              &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;DUR&#38;amp;quot;&#38;amp;gt;=TO_DATE(:4,'YYYY-MM-DD') AND &#38;amp;quot;A&#38;amp;quot;.&#38;amp;quot;DUR&#38;amp;quot;&#38;amp;lt;=TO_DATE(:5,'YYYY-MM-DD'))
   6 - filter(&#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;SCH_PRIM_ALT_IND&#38;amp;quot;=:3 AND &#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;EMPL_RCD&#38;amp;quot;=TO_NUMBER(:2))
   7 - access(&#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;EMPLID&#38;amp;quot;=:1 AND &#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;DUR&#38;amp;quot;&#38;amp;gt;=TO_DATE(:4,'YYYY-MM-DD') AND &#38;amp;quot;M&#38;amp;quot;.&#38;amp;quot;DUR&#38;amp;quot;&#38;amp;lt;=TO_DATE(:5,'YYY
Y-MM-DD'))

-------------------------------------------------------------------------------

PL/SQL procedure successfully completed.
</pre>
<p>The routine above works well but I am happy to consider any changes or improvements.</p>
<p>PS If anybody knows how to use a code tag and not have those horrible green wraparound marks please let me know</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Cron]]></title>
<link>http://ngocthao.wordpress.com/2009/11/10/cron/</link>
<pubDate>Tue, 10 Nov 2009 08:06:10 +0000</pubDate>
<dc:creator>ngocthao</dc:creator>
<guid>http://ngocthao.wordpress.com/2009/11/10/cron/</guid>
<description><![CDATA[Cron: sắp xếp các sự kiện thành một hàng đợi và thực hiện vào một khoảng thời gian.]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Cron: sắp xếp các sự kiện thành một hàng đợi và thực hiện vào một khoảng thời gian.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[HowTo: scaricare torrent da RSS in automatico con cron]]></title>
<link>http://idl3.wordpress.com/2009/11/03/howto-scaricare-torrent-da-rss-in-automatico-con-cron/</link>
<pubDate>Tue, 03 Nov 2009 06:07:41 +0000</pubDate>
<dc:creator>idl3</dc:creator>
<guid>http://idl3.wordpress.com/2009/11/03/howto-scaricare-torrent-da-rss-in-automatico-con-cron/</guid>
<description><![CDATA[Il titolo sarebbe dovuto essere molto piu&#8217; lungo, una cosa del tipo: &#8220;usare uno script i]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Il titolo sarebbe dovuto essere molto piu&#8217; lungo, una cosa del tipo: &#8220;usare uno script in bash per scaricare i file .torrent da un indirizzo <acronym title="Really Simple Syndication">RSS</acronym> per poi farli scaricare da <a href="http://idl3.wordpress.com/2009/09/30/aria2c-il-downloader-senza-interfaccia-grafica-anche-torrent/">aria2c</a> automaticamente grazie a <a href="http://it.wikipedia.org/wiki/Crontab">crontab</a>&#8220;. Tutto e&#8217; cominciato quando ho trovato <a href="http://www.voria.org/files/rsstorrent.sh">questo script in <em>bash</em></a> (scritto da  di <a href="http://www.voria.org/">voRia</a>), vedendolo mi sono detto: &#8220;<em>perche&#8217; fermarsi qui?</em>&#8221; Ma e&#8217; d&#8217;obbligo una premessa, <strong>scaricare le serie televisive e&#8217; un reato</strong>, quindi <strong>non fatelo</strong>, ho usato lo script <strong>solo a titolo di esempio</strong> <em>bla bla bla</em>, ma chi ci crede. Allora <strong>continuiamo</strong>.</p>
<p><img src="http://idl3.wordpress.com/files/2009/11/rss.jpg?w=150" alt="rss" title="rss" width="150" height="137" class="alignleft size-thumbnail wp-image-762" />Prima di tutto prendete quel file e <strong>personalizzatelo</strong>. Per farlo dovete andare sul sito <a href="http://www.ezrss.it/">ezRSS.it</a> e <strong>copiare il link dei feed <a href="http://it.wikipedia.org/wiki/Really_simple_syndication">RSS</a></strong> delle vostre serie preferite. Ad esempio <em>Monk</em>, <em>Dr. House</em> e <em>Warehouse 13</em>. Poi dobbiamo decidere dove scaricare i file <code>.torrent</code> e con quale programma scaricare i <strong>torrent</strong> (<strong>aria2c</strong> nell&#8217;esempio, ma poteva benissimo essere anche <strong>transmissioncli</strong>). Ora possiamo <strong>personalizzare lo script</strong>:</p>
<pre><tt>---8&#60;---
<i><font color="#9A1900">#!/bin/bash</font></i>

<font color="#009900">TORRENTDIRECTORY</font><font color="#990000">=</font><font color="#FF0000">"/home/luca/downloads/torrents/torrentfiles/"</font>
<font color="#009900">RSSFILE</font><font color="#990000">=</font>/tmp/rssfile

<font color="#009900">URL_MONK</font><font color="#990000">=</font><font color="#FF0000">"http://www.ezrss.it/search/index.php?show_name=Monk&#38;date=&#38;quality=HDTV&#38;quality_exact=true&#38;release_group=&#38;mode=rss"</font>
<font color="#009900">URL_WAREHOUSE13</font><font color="#990000">=</font><font color="#FF0000">"http://www.ezrss.it/search/index.php?show_name=Warehouse+13&#38;date=&#38;quality=HDTV&#38;quality_exact=true&#38;release_group=&#38;mode=rss"</font>
<font color="#009900">URL_DRHOUSE</font><font color="#990000">=</font><font color="#FF0000">"http://www.ezrss.it/search/index.php?show_name=House&#38;show_name_exact=true&#38;date=&#38;quality=HDTV&#38;quality_exact=true&#38;release_group=&#38;mode=rss"</font>

<font color="#009900">RSSLINKS</font><font color="#990000">=</font>`echo <font color="#009900">$URL_MONK</font> <font color="#009900">$URL_WAREHOUSE13</font> <font color="#009900">$URL_DRHOUSE</font>`

<i><font color="#9A1900"># Fa in modo che la la directory dove verranno scaricati i torrent esista</font></i>
mkdir -p <font color="#009900">$TORRENTDIRECTORY</font>

<i><font color="#9A1900"># Scarica gli RSS</font></i>
wget <font color="#009900">$RSSLINKS</font> -O <font color="#009900">$RSSFILE</font> -o /dev/null

<i><font color="#9A1900"># Recupera tutti i link .torrent dal file RSS</font></i>
<font color="#009900">LINKS</font><font color="#990000">=</font>`cat <font color="#009900">$RSSFILE</font> <font color="#990000">&#124;</font> grep <font color="#FF0000">"&#60;link&#62;"</font> <font color="#990000">&#124;</font> grep <font color="#990000">.</font>torrent`
<font color="#009900">LINKS</font><font color="#990000">=</font>`echo <font color="#009900">$LINKS</font> <font color="#990000">&#124;</font> sed <font color="#FF0000">"s:&#60;link&#62;::g"</font>`
<font color="#009900">LINKS</font><font color="#990000">=</font>`echo <font color="#009900">$LINKS</font> <font color="#990000">&#124;</font> sed <font color="#FF0000">"s:&#60;/link&#62;::g"</font>`

<i><font color="#9A1900"># Recupera tutte le date dal file RSS</font></i>
<font color="#009900">DATES</font><font color="#990000">=</font>`cat <font color="#009900">$RSSFILE</font> <font color="#990000">&#124;</font> grep <font color="#FF0000">"&#60;pubDate&#62;"</font>`
<font color="#009900">DATES</font><font color="#990000">=</font>`echo <font color="#009900">$DATES</font> <font color="#990000">&#124;</font> sed <font color="#FF0000">"s:&#60;pubDate&#62;::g"</font>`
<font color="#009900">DATES</font><font color="#990000">=</font>`echo <font color="#009900">$DATES</font> <font color="#990000">&#124;</font> sed <font color="#FF0000">"s:&#60;/pubDate&#62;::g"</font>`

<i><font color="#9A1900"># Conta il numero di torrent recuperati</font></i>
<font color="#009900">num</font><font color="#990000">=</font><font color="#993399">0</font>
<b><font color="#0000FF">for</font></b> LINK <b><font color="#0000FF">in</font></b> <font color="#009900">$LINKS</font><font color="#990000">;</font> <b><font color="#0000FF">do</font></b>
	<b><font color="#0000FF">let</font></b> <font color="#FF0000">"num += 1"</font>
<b><font color="#0000FF">done</font></b>

<i><font color="#9A1900"># Recupera solo i dati che ci interessano della data,</font></i>
<i><font color="#9A1900"># cioè giorno, mese e anno (campi 2, 3 e 4).</font></i>
<font color="#009900">DAYS</font><font color="#990000">=</font><font color="#FF0000">""</font>
<font color="#009900">MONTHS</font><font color="#990000">=</font><font color="#FF0000">""</font>
<font color="#009900">YEARS</font><font color="#990000">=</font><font color="#FF0000">""</font>
<font color="#009900">counter</font><font color="#990000">=</font><font color="#993399">0</font>
<b><font color="#0000FF">for</font></b> DATE <b><font color="#0000FF">in</font></b> <font color="#009900">$DATES</font><font color="#990000">;</font> <b><font color="#0000FF">do</font></b>
	<b><font color="#0000FF">let</font></b> <font color="#FF0000">"counter += 1"</font>
	<b><font color="#0000FF">if</font></b> <font color="#990000">[</font> <font color="#009900">$counter</font> -eq <font color="#993399">2</font> <font color="#990000">];</font> <b><font color="#0000FF">then</font></b>
		<font color="#009900">DAYS</font><font color="#990000">=</font>`echo <font color="#009900">$DAYS</font> <font color="#009900">$DATE</font>`
	<b><font color="#0000FF">fi</font></b>
	<b><font color="#0000FF">if</font></b> <font color="#990000">[</font> <font color="#009900">$counter</font> -eq <font color="#993399">3</font> <font color="#990000">];</font> <b><font color="#0000FF">then</font></b>
		<font color="#009900">MONTHS</font><font color="#990000">=</font>`echo <font color="#009900">$MONTHS</font> <font color="#009900">$DATE</font>`
	<b><font color="#0000FF">fi</font></b>
	<b><font color="#0000FF">if</font></b> <font color="#990000">[</font> <font color="#009900">$counter</font> -eq <font color="#993399">4</font> <font color="#990000">];</font> <b><font color="#0000FF">then</font></b>
		<font color="#009900">YEARS</font><font color="#990000">=</font>`echo <font color="#009900">$YEARS</font> <font color="#009900">$DATE</font>`
	<b><font color="#0000FF">fi</font></b>
	<b><font color="#0000FF">if</font></b> <font color="#990000">[</font> <font color="#009900">$counter</font> -eq <font color="#993399">6</font> <font color="#990000">];</font> <b><font color="#0000FF">then</font></b>
		<font color="#009900">counter</font><font color="#990000">=</font><font color="#993399">0</font>
	<b><font color="#0000FF">fi</font></b>
<b><font color="#0000FF">done</font></b>

<i><font color="#9A1900"># Ricostruisce tutte le date nel formato finale che ci interessa.</font></i>
<i><font color="#9A1900"># Esempio: 3 novembre 2009 -&#62; 03112009</font></i>
<font color="#009900">DATES</font><font color="#990000">=</font><font color="#FF0000">""</font>
<b><font color="#0000FF">for</font></b> i <b><font color="#0000FF">in</font></b> `seq <font color="#009900">$num</font>`<font color="#990000">;</font> <b><font color="#0000FF">do</font></b>
	<font color="#009900">DAY</font><font color="#990000">=</font>`echo <font color="#009900">$DAYS</font> <font color="#990000">&#124;</font> cut -d<font color="#FF0000">' '</font> -f <font color="#009900">$i</font>`
	<b><font color="#0000FF">case</font></b> `echo <font color="#009900">$MONTHS</font> <font color="#990000">&#124;</font> cut -d<font color="#FF0000">' '</font> -f <font color="#009900">$i</font>` <b><font color="#0000FF">in</font></b>
		Jan<font color="#990000">)</font>
			<font color="#009900">MONTH</font><font color="#990000">=</font><font color="#993399">01</font>
			<font color="#990000">;;</font>
		Feb<font color="#990000">)</font>
			<font color="#009900">MONTH</font><font color="#990000">=</font><font color="#993399">02</font>
			<font color="#990000">;;</font>
		Mar<font color="#990000">)</font>
			<font color="#009900">MONTH</font><font color="#990000">=</font><font color="#993399">03</font>
			<font color="#990000">;;</font>
		Apr<font color="#990000">)</font>
			<font color="#009900">MONTH</font><font color="#990000">=</font><font color="#993399">04</font>
			<font color="#990000">;;</font>
		May<font color="#990000">)</font>
			<font color="#009900">MONTH</font><font color="#990000">=</font><font color="#993399">05</font>
			<font color="#990000">;;</font>
		Jun<font color="#990000">)</font>
			<font color="#009900">MONTH</font><font color="#990000">=</font><font color="#993399">06</font>
			<font color="#990000">;;</font>
		Jul<font color="#990000">)</font>
			<font color="#009900">MONTH</font><font color="#990000">=</font><font color="#993399">07</font>
			<font color="#990000">;;</font>
		Aug<font color="#990000">)</font>
			<font color="#009900">MONTH</font><font color="#990000">=</font><font color="#993399">08</font>
			<font color="#990000">;;</font>
		Sep<font color="#990000">)</font>
			<font color="#009900">MONTH</font><font color="#990000">=</font><font color="#993399">09</font>
			<font color="#990000">;;</font>
		Oct<font color="#990000">)</font>
			<font color="#009900">MONTH</font><font color="#990000">=</font><font color="#993399">10</font>
			<font color="#990000">;;</font>
		Nov<font color="#990000">)</font>
			<font color="#009900">MONTH</font><font color="#990000">=</font><font color="#993399">11</font>
			<font color="#990000">;;</font>
		Dec<font color="#990000">)</font>
			<font color="#009900">MONTH</font><font color="#990000">=</font><font color="#993399">12</font>
			<font color="#990000">;;</font>
	<b><font color="#0000FF">esac</font></b>
	<font color="#009900">YEAR</font><font color="#990000">=</font>`echo <font color="#009900">$YEARS</font> <font color="#990000">&#124;</font> cut -d<font color="#FF0000">' '</font> -f <font color="#009900">$i</font>`
	<font color="#009900">DATES</font><font color="#990000">=</font><font color="#009900">$DATES$DAY$MONTH$YEAR</font>`echo <font color="#FF0000">" "</font>`
<b><font color="#0000FF">done</font></b>

<i><font color="#9A1900"># Il file RSS scaricato non ci serve più</font></i>
rm <font color="#009900">$RSSFILE</font>

<i><font color="#9A1900"># A questo punto abbiamo:</font></i>
<i><font color="#9A1900"># - $LINKS : lista ordinata di tutti i file .torrent</font></i>
<i><font color="#9A1900"># - $DATES : lista ordinata di tutte le date</font></i>

<i><font color="#9A1900"># Scarica i .torrent di ieri</font></i>
cd <font color="#009900">$TORRENTDIRECTORY</font>
<b><font color="#0000FF">for</font></b> i <b><font color="#0000FF">in</font></b> `seq <font color="#009900">$num</font>`<font color="#990000">;</font> <b><font color="#0000FF">do</font></b>
	<b><font color="#0000FF">if</font></b> <font color="#990000">[</font> `date <font color="#990000">+%</font>d<font color="#990000">%</font>m<font color="#990000">%</font>Y -d <font color="#FF0000">"yesterday"</font>` <font color="#990000">==</font> `echo <font color="#009900">$DATES</font> <font color="#990000">&#124;</font> cut -d<font color="#FF0000">' '</font> -f <font color="#009900">$i</font>` <font color="#990000">];</font> <b><font color="#0000FF">then</font></b>
		<font color="#009900">TORRENT</font><font color="#990000">=</font>`echo <font color="#009900">$LINKS</font> <font color="#990000">&#124;</font> cut -d<font color="#FF0000">' '</font> -f <font color="#009900">$i</font>`
		wget -c <font color="#FF0000">"$TORRENT"</font> -o /dev/null
	<b><font color="#0000FF">fi</font></b>
<b><font color="#0000FF">done</font></b>

<i><font color="#9A1900"># Facciamo scaricare i file torrent con Aria2c</font></i>
aria2c <font color="#990000">*.</font>torrent

---8&#60;---</tt></pre>
<p><img src="http://idl3.wordpress.com/files/2009/11/torrent.jpeg?w=150" alt="torrent" title="torrent" width="150" height="150" class="alignright size-thumbnail wp-image-763" />Copiamo e <strong>incolliamo</strong> in un file vuoto rinominato <code>rsstorrentserie</code>, mettiamolo dove piu&#8217; ci aggrada (ad esempio in <code>/home/UTENTE/script/</code>) e rendiamolo eseguibile:<br />
<code># chmod a+x rsstorrentserie</code><br />
A questo punto non ci resta che <strong>programmare</strong> lo script con <code>crontab</code> in modo che ogni settimana venga avviato.</p>
<p>Per far questo dobbiamo sapere come usare <a href="http://guide.debianizzati.org/index.php/Cron">cron</a>. Per questo ci sono tante guide, ad esempio questa guida sull&#8217;<a href="http://guide.debianizzati.org/index.php/Utilizzo_del_servizio_di_scheduling_Cron">utilizzo del servizio di scheduling Cron</a>.</p>
<p><img src="http://idl3.wordpress.com/files/2009/11/cron.gif?w=150" alt="cron" title="cron" width="150" height="117" class="alignleft size-thumbnail wp-image-764" />Dobbiamo far si che alle 20:30 di ogni domenica <strong>venga eseguito il nostro script</strong>. Possiamo farlo in <strong>vari modi</strong>:</p>
<p><strong>1)</strong> Creiamo un file nella directory <code>/etc/cron.d/</code> col nome che preferiamo e con questo contenuto:</p>
<pre>---8&#60;---
# /etc/cron.d/nomechepreferite

SHELL=/bin/sh
PATH=/home/UTENTE/script

30 20 * * 0   UTENTE	/home/UTENTE/script/rsstorrentserie
---8&#60;---</pre>
<p>in questo modo alle ore 20:30 di ogni domenica verra&#8217; avviato il nostro script (<strong>solo se il computer e&#8217; acceso</strong>).</p>
<p><strong>2)</strong> L&#8217;altro metodo e&#8217; quello di scrivere il comando:<br />
<code>$ crontab -e</code><br />
scrivere tutto il necessario nell&#8217;editor che si aprira&#8217; e dopo uscire dall&#8217;editor. Per vedere se abbiamo scritto tutto giusto possiamo scrivere questo comando:<br />
<code>$ crontab -l</code><br />
se dovessimo aver sbagliato o comunque per cancellare i compiti usiamo questo comando:<br />
<code>$ crontab -r</code><br />
per cancellare solo il compito visto in questo esempio:<br />
<code>$ crontab -r filecompitoquestoesempio</code></p>
<p><strong>3)</strong> Oppure possiamo scrivere il contenuto che abbiamo visto prima:</p>
<pre>---8&#60;---
# /etc/cron.d/nomechepreferite

SHELL=/bin/sh
PATH=/home/UTENTE/script

30 20 * * 0   UTENTE	/home/UTENTE/script/rsstorrentserie
---8&#60;---</pre>
<p>in un file dove vogliamo (ad esempio <code>/home/UTENTE/dovevogliamo/</code>) e darlo in pasto a cron con questo comando:<br />
<code>$ crontab /home/UTENTE/dovevogliamo/file</code><br />
sara&#8217; lui che si occupera&#8217; del resto.</p>
<p>In realta&#8217; ci sono anche altri modi, come ad esempio scrivere direttamente nel file <code>/etc/crontab</code>, ma se dovessi proprio scegliere <strong>preferisco il terzo metodo</strong> (<code>crontab file</code>). Adesso aspettiamo le 20:30 di domenica per vedere se funziona tutto.</p>
<p>Pensandoci bene, lo script cosi&#8217; com&#8217;e&#8217; scarica i torrent nuovi, con la data del giorno prima, sarebbe dunque piu&#8217; corretto nel <code>crontab</code> inserire al posto di:</p>
<pre>---8&#60;---
30 20 * * 0   UTENTE	/home/UTENTE/script/rsstorrentserie
---8&#60;---</pre>
<p><strong>questo</strong>:</p>
<pre>---8&#60;---
30 14 * * *   UTENTE	/home/UTENTE/script/rsstorrentserie
---8&#60;---</pre>
<p>in modo che lo script venga eseguito <strong>alle 14:30 di ogni giorno</strong>. Se sappiamo la data esatta dell&#8217;uscita dei torrent, ad esempio <strong>il mercoledi&#8217; e il venerdi&#8217;</strong>, possiamo anche scrivere:</p>
<pre>---8&#60;---
30 14 * * 4,6   UTENTE	/home/UTENTE/script/rsstorrentserie
---8&#60;---</pre>
<p>in questo modo lo script verra&#8217; eseguito alle 14:30 <strong>il giovedi&#8217; e il sabato</strong>.</p>
<p>Per le <strong>varie possibilita&#8217;</strong> vedete voi, anche <strong>modificando lo script</strong> in modo che scarichi tutti i torrent non del giorno prima ma di quella <strong>settimana</strong>, cosi&#8217; da avviare lo script solo un giorno la settimana.</p>
<hr />
<p style="text-align:right;"><a href="#content" title="torna su">[^] torna su</a>&#160;&#124;&#160;<a href="http://postli.com/post?u=http://idl3.wordpress.com/2009/11/03/howto-scaricare-torrent-da-rss-in-automatico-con-cron/&#38;t=HowTo: scaricare torrent da RSS in automatico" title="Post to Postli" style="color:blue;text-decoration:none;">post<span style="color:orange;">&#60;</span><span style="color:red;">li</span><span style="color:orange;">&#62;</span></a>&#160;&#124;&#160;<a href="http://www.wikio.it/vote?url=http://idl3.wordpress.com/2009/11/03/howto-scaricare-torrent-da-rss-in-automatico-con-cron/" target="_blank"><img src="http://www.wikio.it/shared/img/vote/wikio2.gif" border="0" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Scripted backups.]]></title>
<link>http://hwdbbefe.wordpress.com/2009/10/28/scripted-backups/</link>
<pubDate>Wed, 28 Oct 2009 09:12:31 +0000</pubDate>
<dc:creator>firelynx</dc:creator>
<guid>http://hwdbbefe.wordpress.com/2009/10/28/scripted-backups/</guid>
<description><![CDATA[Many people are struggling with how to deal with their backups. Normally backups are a problem handl]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Many people are struggling with how to deal with their backups. Normally backups are a problem handled by some administrator who copies a whole bunch of stuff onto a tape cassette. Often without knowing how, if even possible to restore everything from the data on the tape cassette.</p>
<p>I approached this at a different angle.</p>
<p>As developers we needed a staging environment for the application we are developing. Using the live servers is not okay in my opinion. So I found an old P4 box with 1GB ram. Slapped in a new HDD for the databases and started setting this up as a development server. Of course, porting the code to make it mobile enough to move it to this server was one thing, which is another story. But getting concurrent versions of the databases onto this server was were the backups came into play.</p>
<p>Using the development server as a test case for the backups, I had everything I needed to build a true case where I could assure that each and every backup taken would work. Each backup is restored to the development server and as we developers use the development server, we see if some data goes terribly wrong. Of course, this does not protect us from the scenario where some data is malformed in a uniformed way, producing false positives. However, all data which goes into our system is backed up separately, so everything can be rebuilt if needed. This data is checked via md5 hashes, so no malformation is possible there.</p>
<p>So, the backups are taken to a backup server, custom built for the purpose. This server is an office version. We wanted an out-of-the-server-park backup, so we decided to put a server at our office. The box is custom built by myself and based on a Chieftec chassis with an Intel motherboard and Intel processor. I used a highpoint rocketraid 3210 as a RAID controller. I built a RAID5 from four Western Digital 1TB hard drives. We also have two spares in the server, so in case we need to rebuild the RAID we do not have to wait for a delivery.</p>
<p><strong>A word or two on security.</strong></p>
<p>When doing cross server backup transfers, you must always make sure you know your security priorities. In my case I trust the backup server far more than the live servers. This is often how the case should be in my opinion. The backup servers are exposed to no one but the live servers and the developers. and the live servers are exposed to the whole world. Thus, the more likely first target of an attack would be the live servers. If the backup servers trust the live servers, and the live servers are compromised, the backup server will be compromised as well. This is why we build the backup scripts on the backup server and make them fetch the data from the live servers, rather than having the live servers push the data to the backup server.</p>
<p>The backup scripts are in our case built in php, so all developers at this  company can understand them. I would rather have built them in straight bash or perhaps python, but the advantage of more people being able to understand all code is far greater than having used &#8220;that cool programming language&#8221;. Of course the php executes complex shell commands to do most of the actual work, but the flow of the program is entirely php.</p>
<p><strong>So, how do you set all this up?</strong></p>
<p>The way to set up these kind of scripts are with ssh certificates, crontab and some basic php code.</p>
<p>First you need to set up a user on the live servers who will have only the privileges of reading the files/databases which needs to be backed up. I&#8217;m calling this user &#8216;backup&#8217; for easy reference.<br />
the adduser command is slightly different in many distros, so read up on it if you are unsure.</p>
<blockquote><p>man adduser</p></blockquote>
<p>Secondly you need to give the backup user on your live server the public key of the backup user on your backup server. So log on to your backup server as your backup user and type:</p>
<blockquote><p>ssh-keygen -t rsa</p></blockquote>
<p>a file &#8220;id_rsa.pub&#8221; should be generated in the .ssh directory in your home directory (~/.ssh/id_rsa.pub). This file contains one(1) line and this line is this user at this machines public key. It identifies this user at this machine. What you need to do now is to transfer this line into the live servers&#8217; authorized keys file. (~/.ssh/authorized_keys). This file may not even exist on the live servers, but if it does, make sure only to add your public key line to the end of this file. Do not overwrite. The magical unix command for doing this would be:</p>
<blockquote><p>cat ~/.ssh/id_rsa.pub &#124; ssh backup@your.liveserver &#8220;cat &#62;&#62; ~/.ssh/authorized_keys&#8221;</p></blockquote>
<p>of course, you should double check these kind of things manually and not rely on a copy-pasted command from blogs like mine. The command above does give you a hint on how the backups are transferred though.<br />
After you have put the backup user of the backup servers public key into the authorized keys file of the backup user on the live server, you should now be able to log in from the backup server as the backup user on the live server as the backup user, without being prompted for a password. If this is not the case, you&#8217;ve done something wrong. Start from the beginning.</p>
<p>So, now we need to start writing the actual script which controls the flow of the backup process. I will now write an explanation which can be applied into any kind of programming language.</p>
<p>First thing we need to do is to get the information on what databases we need to back up from the server. We do this with an easy shell command executed from within the script, and then parsing the output it gives us. Why do we not use a local mysql client implementation to query the database directly and get a mysql resultset? Simple. We do not want to expose the live mysql to the outside world. So what do is we issue the following command in a shell controlled by the script (so we can get the output into our code and use it):</p>
<blockquote><p>ssh backup@your.liveserver mysqlshow</p></blockquote>
<p>This will initiate a new ssh connection to your live server, and the command mysqlshow is sent over that connection, just as if you would have logged in and done it yourself. All output from mysql will be returned and will end up in your script.<br />
Once you have gotten this down you will have to parse what mysql throws at you. This should be a no brainer. I use this regular expression /[\w]+/ because all we really need to do is remove all spaces and pipes. Of course, this regular expression must match all your databases you need to backup. Maybe you only have one database to back up, in which case, you do not need to do this step really.</p>
<p>Next thing in the script is to, for each database we want to backup, get the dump from the database. But how do we do this without actually writing everything to disk as dump files? Easy. This command may seem complex, but I will walk you trough it step by step:</p>
<blockquote><p>ssh backup@your.liveserver &#8220;mysqldump databasename &#124; gzip -c&#8221; &#62; /your_backup_location/databasename_date.mysqldump.gz</p></blockquote>
<p>ok. this may look scary for some of you. If you are not familiar with the mysqldump command, what it does is it outputs in plaintext a full recreation script for the database in question. So we initiate an ssh connection and tell the server to start outputting the whole database. Then we take all which it outputs and hand it over to gzip, which zips the output and with the -c parameter it just passes the zipped output on. All of this ends up on your side of the ssh connection, where you in turn tell it to go into the file /your_backup_location/databasename_date.mysqldump.gz<br />
All data is zipped and done when it gets to your side of the connection.<br />
Restoring from this file is also easy. The following command can be used for that:</p>
<blockquote><p>cat /your_backup_location/databasename_date.mysqldump.gz &#124; ssh backup@your.liveserver &#8220;gunzip -c &#124; mysql databasename&#8221;</p></blockquote>
<p>So, having the script done we need to put this into a crontab on the backup server. Note that nothing except for the authorized_keys have been changed on the live server.<br />
crontab -e<br />
lets you edit your crontab. Here you need to write a crontab line. The crontab may be empty, in which case it is hard to remember which order everything should be put, so here is a reference:</p>
<blockquote><p>min     hour     day_of_month     month      day_of_week      command to be executed</p></blockquote>
<p>So if we want this script to be executed every evening at 23:42 except for on Sundays, because then the server does other heavy load things, we would write something like this:</p>
<blockquote><p>42      23         *           *            1-6        /path/to/script</p></blockquote>
<p>A better reference for crontab can be found here: <a title="Unix Crontab at Adminschoice" href="http://www.adminschoice.com/docs/crontab.htm#Crontab%20file" target="_blank">http://www.adminschoice.com/docs/crontab.htm#Crontab%20file</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[a simple cron file is better than cron-apt]]></title>
<link>http://faltufund.wordpress.com/2009/10/25/a-simple-cron-file-is-better-than-cron-apt/</link>
<pubDate>Sun, 25 Oct 2009 20:21:57 +0000</pubDate>
<dc:creator>faltufund</dc:creator>
<guid>http://faltufund.wordpress.com/2009/10/25/a-simple-cron-file-is-better-than-cron-apt/</guid>
<description><![CDATA[ive been trying to get cron-apt to download and install packages. i was able to get it to update and]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>ive been trying to get cron-apt to download and install packages.  i was able to get it to update and download, but never to install, and i dont want to know how to do it anymore.  really all you need to do is put an executable file in /etc/cron.daily/cronaptitude with</p>
<p>#!/bin/bash<br />
aptitude update<br />
aptitude -y safe-upgrade</p>
<p>that&#8217;s all i wanted, and its so much simpler than cron-apt.  i know there&#8217;s a &#8220;safety&#8221; issue with automatically upgrading, but ive stopped looked at specific packages years ago when i upgraded and havent had problems.  sometimes X will break or the kernel will break, but this is not a problem.  its easier to fix this when it happens once every couple of years than it is to not have cron upgrading automatically and then every week or 2 having a giant upgrade. </p>
<p>another thing which cropped up was that if i put that script in /etc/cron.daily then it works, but if i have root do crontab -e then it complains about paths.  then in root&#8217;s crontab you have to add the line</p>
<p>PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:$PATH</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Da Dedicação de Bresson]]></title>
<link>http://literaturafugaz.wordpress.com/2009/10/20/da-dedicacao-de-bresson/</link>
<pubDate>Tue, 20 Oct 2009 02:09:23 +0000</pubDate>
<dc:creator>Guilherme I.</dc:creator>
<guid>http://literaturafugaz.wordpress.com/2009/10/20/da-dedicacao-de-bresson/</guid>
<description><![CDATA[Escavando a pilha de asneiras que a sociedade joga sobre os mortos, podemos encontrar bastante coisa]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Escavando a pilha de asneiras que a sociedade joga sobre os mortos, podemos encontrar bastante coisa útil. Entre o montante encontra-se discursos vazios, ideologias baratas, elogios desnecessários. Ao mesmo tempo, por meio de uma análise minuciosa, é possível resgatar o estudo, o esforço e a dedicação.</p>
<p>Em uma recente edição da revista Bravo, diferentes fotógrafos comentaram sobre a técnica e o estilo de Henry Cartier-Bresson. Os elogios repetiam-se pelas colunas da reportagem. Ou os entrevistados tinham pouquíssima criatividade e um vocabulário à la jardim de infância ou realmente fracas definições como &#8220;decisivo&#8221; e &#8220;incomparável&#8221; encaixam-se por unânimidade ao fotógrafo francês.</p>
<p>Bresson, mais do que um exímio fotojornalista, foi um homem que desde pequeno possuía uma paixão. Do dia em que ganhou uma máquina fotográfica Box Brownie à sua participação na Segunda Guerra Mundial já há uma experiência de vida inigualável. Sua carreira nas revistas Life e Vogue com certeza fortaleceram sua perspectiva e técnica.</p>
<p>No entanto, quantos não devem ter sido os filmes queimados ou as fotos descartadas pelos inúmeros editores ao longo da carreira do francês? Bresson, como todos, era um ser humano. Convivia com altos e baixos.  Dedicou-se diariamente para obter excelência. Contudo, não significa que, desde os tempos da primeira 35mm, suas imagens já tinham seu ponto de vista especialíssimo.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[get_iplayer and cron]]></title>
<link>http://rwmj.wordpress.com/2009/10/18/get_iplayer-and-cron/</link>
<pubDate>Sun, 18 Oct 2009 18:00:05 +0000</pubDate>
<dc:creator>rich</dc:creator>
<guid>http://rwmj.wordpress.com/2009/10/18/get_iplayer-and-cron/</guid>
<description><![CDATA[What&#8217;s better than BBC&#8217;s iPlayer? get_iplayer of course, a Perl script that rips program]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>What&#8217;s better than <a href="http://www.bbc.co.uk/iplayer/">BBC&#8217;s iPlayer</a>?  <a href="http://linuxcentre.net/getiplayer/">get_iplayer</a> of course, a Perl script that rips programmes to your local machine.</p>
<p>I now have get_iplayer set up with cron to download TV programmes that I&#8217;m interested in (have a guess from the list below):</p>
<pre>
0 3 * * *	cd Desktop &#38;&#38; get_iplayer -l --nopurge --get Beatle
30 3 * * * 	cd Desktop &#38;&#38; get_iplayer -l --nopurge --get Brooker
0 4 * * * 	cd Desktop &#38;&#38; get_iplayer -l --nopurge --get Japan
30 4 * * *      cd Desktop &#38;&#38; get_iplayer -l --nopurge --get Horizon
0 5 * * *       cd Desktop &#38;&#38; get_iplayer -l --nopurge --get Buzzcocks
</pre>
<h4>Update</h4>
<p>Everyone points out in the comments that get_iplayer has a <code>--pvr</code> option that makes this even easier.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[bash and cron]]></title>
<link>http://anonir.wordpress.com/2009/10/13/bash-and-cron/</link>
<pubDate>Tue, 13 Oct 2009 15:45:23 +0000</pubDate>
<dc:creator>anonir</dc:creator>
<guid>http://anonir.wordpress.com/2009/10/13/bash-and-cron/</guid>
<description><![CDATA[Setting up cron in Ubuntu is simple enough as described in the Ubuntu wiki. But what they don&#8217;]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Setting up cron in Ubuntu is simple enough as described in the <a href="https://help.ubuntu.com/community/CronHowto">Ubuntu wiki</a>. But what they don&#8217;t mention is that by default cron uses /bin/sh for its SHELL env variable. That may cause a problem if you try to set up a bash script in cron. To prevent that from happening, you need to define the SHELL variable for your user crontab to point to /bin/bash.</p>
<p>In the console type:</p>
<pre>crontab -e</pre>
</p>
<p></p>
<p>Add the following line at the top:</p>
<pre>SHELL=/bin/bash</pre>
</p>
<p></p>
<p>Your crontab should look something like this:</p>
<pre>SHELL=/bin/bash
# m h  dom mon dow   command
*/5 * * * * /usr/local/bin/my_bash_script</pre></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Power Saving on your Lacie Network Space]]></title>
<link>http://svgblog.wordpress.com/2009/10/11/power-saving-on-your-lacie-network-space/</link>
<pubDate>Sun, 11 Oct 2009 13:23:44 +0000</pubDate>
<dc:creator>svgblog</dc:creator>
<guid>http://svgblog.wordpress.com/2009/10/11/power-saving-on-your-lacie-network-space/</guid>
<description><![CDATA[After tweaking my nas to be able to backup my Vista machines to it, I started wondering about its po]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>After tweaking my nas to be able to backup my Vista machines to it, I started wondering about its power consumption and lifetime since its disk never seems to spin down. Of course I could get off my chair and turn the thing off when I&#8217;m not using it, but that kinda kills the adea of a network share, doesn&#8217;t it ?<br />
Since hdparm doesn&#8217;t work (it&#8217;s a sata disk) first thing I thought of was to try to spin down the disk after a certain idle time using dsparm. No luck there. As a Windows kinda guy, I was unable to get any pre-compiled of self-compiled version of sdparm working.</p>
<p>To make a long story short, I finally rested my case by powering off the device at night using a cron job. Not exactly what I had in mind, but it sure meets the purpose of saving on my electricity bills. Note that, for some reason, <strong>poweroff</strong> reboots the device, and <strong>halt</strong> powers it off…</p>
<p>If you want to do so on you Lacie, here you go:</p>
<ul style="margin-left:54pt;">
<li>You need shell access, I use telnet. If you don&#8217;t: check <a href="http://svgblog.wordpress.com/2009/09/30/solved-vista-backup-with-lacie-network-space/">here</a></li>
<li>First, make a copy of your crontab entries (there should be one entry from you mediaserver).</li>
<blockquote>
<li>Crontab –l &#62; tempcron</li>
</blockquote>
<li>Now edit tempcron :</li>
<blockquote>
<li>vi tempcron</li>
</blockquote>
<li>Press ESC, then i to start editing</li>
<li>Add a line like the one below to shut down at 2:30 AM:</li>
<blockquote>
<li>30 2 * * * /sbin/halt</li>
</blockquote>
<li>Press ESC, then :, then wq, then enter to save and close the editor</li>
<li>Now apply to crontab:</li>
<blockquote>
<li>crontab tempcron</li>
</blockquote>
<li>Check your conjobs:</li>
<blockquote>
<li>crontab –l</li>
</blockquote>
<li>Delete the tempcron file:</li>
<blockquote>
<li>rm tempcron</li>
</blockquote>
</ul>
<p>That&#8217;s it! Now your nas will poweroff at night automatically.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[...el mundo no piensa.]]></title>
<link>http://nosquedalapalabra.wordpress.com/2009/10/07/el-mundo-no-piensa/</link>
<pubDate>Wed, 07 Oct 2009 22:21:03 +0000</pubDate>
<dc:creator>labalaustra</dc:creator>
<guid>http://nosquedalapalabra.wordpress.com/2009/10/07/el-mundo-no-piensa/</guid>
<description><![CDATA[  “El mundo está detenido ante el hambre que asola a los pueblos. Mientras haya desequilibrio económ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div id="post-813">
<p style="text-align:justify;"><em><strong> </strong></em></p>
<p style="text-align:justify;"><em><strong>“El mundo está detenido ante el hambre que asola a los pueblos. Mientras haya desequilibrio económico, el mundo no piensa. Yo lo tengo visto. Van dos hombres por la orilla de un río. Uno es rico, otro es pobre. Uno lleva la barriga llena, y el otro pone sucio el aire con sus bostezos. Y el rico dice: ‘¡Oh, qué barca más linda se ve por el agua! Mire, mire usted el lirio que florece en la orilla’. Y el pobre reza: ‘Tengo hambre, no veo nada. Tengo hambre, mucha hambre’. Natural. El día que el hambre desaparezca, va a producirse en el mundo la explosión espiritual más grande que jamás conoció la humanidad. Nunca jamás se podrán figurar los hombres la alegría que estallará el día de la gran revolución. ¿Verdad que te estoy hablando en socialista puro?”</strong></em></p>
<p style="text-align:right;"><strong><span style="color:#000000;">Federico García Lorca<br />
Entrevista en La Voz, Madrid, 7 de abril de 1936.</span></strong></p>
<p> </p>
<h2><a href="http://cuaderno.josesaramago.org/2009/10/07/dias-felices/" target="_blank">Días felices</a></h2>
<p><a href="http://cuaderno.josesaramago.org/2009/10/07/dias-felices/" target="_blank">By José Saramago</a></p>
<div>
<div>
<p style="text-align:justify;">El excelente artículo de Umberto Eco titulado “Un blogero llamado Saramago” que fue publicado hace algunos días en “La Repubblica”, apareció hoy en “El País” y saldrá mañana en las páginas del “Diario de Noticias”. Ese conjunto de textos breves, al que bauticé para la edición en libro con el nombre discreto de “El Cuaderno”, nació con suerte. Traducido ya al castellano, al catalán y al italiano, ha encontrado ahora el mejor de los valedores posibles en la persona de Umberto Eco, cuya perspicaz análisis viene sabiamente temperada por la gracia de la escritura y por la sutileza del humor. No tengo derecho a alargarme, mucho menos a comentar lo que Eco escribió. Me basta la felicidad que siento. En el pasar de todos estos años, otros libros míos fueron acogidos con generosidad y simpatía, pero ninguno como éste. Soy, en este momento, el más agradecido de los escritores.</p>
<p>06 de Octubre de 2009</p></div>
<h6>Esta entrada fue publicada el a las Octubre 7, 2009 y está archivada bajo las categorías <a href="http://es.wordpress.com/tag/el-cuaderno-de-saramago/">El cuaderno de Saramago.</a></h6>
<p> </p></div>
</div>
<p style="text-align:justify;">&#8220;Se ha hablado del ateísmo militante de Saramago. En efecto, sus polémicas no se dirigen contra Dios: una vez admitido que su “eternidad es sólo la de un eterno no ser”, Saramago podría haberse quedado tranquilo. Su hastío se dirige contra las religiones […] Saramago ha azotado a las religiones como germen de conflictos: “Las religiones, todas sin excepción, no servirán nunca para acercar y reconciliar a los hombres; todo lo contrario, han sido y siguen siendo causa de sufrimientos inenarrables, de matanzas, de una monstruosa violencia física y espiritual” ….</p>
<p style="text-align:justify;"> </p>
<p style="text-align:right;">Umberto Eco,  prólogo a <em>El Cuaderno</em> , de José Saramago.</p>
<p> </p>
<p>Fuente l  <a href="http://www.radiocable.com/jose-saramago-cain035.html" target="_blank">Radiocable (inagotable)</a></p>
<p style="text-align:justify;"> </p>
<p style="text-align:justify;"> Además, como se ha observado ya en el contexto de la C<em>âd Goddeu, </em>las judias se utilizaban en los tiempos clásicos como talismán homeopático contra las brujas y los espíritus: se ponía una judia en la boca y se la escupía al visitante; y en las fiestas romanas de las <em>Lemurias </em>cada cabeza de familia arrojaba judias negras para los<em> Lemures,</em> o espectros, mientras decía: &#8220;Con éstas me redimo a mí mismo y a mi familia&#8221;.</p>
<p style="text-align:justify;"> </p>
<p style="text-align:center;"><span style="text-decoration:underline;">Fuente original</span></p>
<p style="text-align:center;">The White Golddess- A Historical Grammar of Poetic Mytch. Robert Graves</p>
<p style="text-align:center;"><span style="font-family:georgia;">© </span>Robert Graves, 1948</p>
<p style="text-align:center;"><span style="font-family:georgia;">© Ed. cast.: Alianza Editorial S.A. Madrid.1983</span></p>
<p style="text-align:center;"><span style="font-family:georgia;"> </span></p>
<p style="text-align:justify;"> </p>
<p style="text-align:right;">Robert Graves cita a Ovidio  identificando a Cardea ,  en su obra &#8220;La Diosa Blanca&#8221;:</p>
<p style="text-align:right;"><em>&#8220;Su poder consiste en abrir lo que está cerrado y en cerrar lo que está abierto.&#8221;</em></p>
<p style="text-align:right;"> </p>
<p style="text-align:right;"><em> A veces nada&#8230;</em></p>
<p style="text-align:center;"> </p>
<p style="text-align:right;"><strong><span style="color:#000000;">A Lu&#8230; &#8220;forjadora de utopías&#8221;&#8230;</span></strong></p>
<p style="text-align:right;"><strong><span style="color:#000000;"> </span></strong></p>
<p style="text-align:justify;"><strong><span style="color:#000000;"> </span></strong></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[crontab file location]]></title>
<link>http://oracledelivery.wordpress.com/2009/10/07/crontab-file-location/</link>
<pubDate>Wed, 07 Oct 2009 10:45:28 +0000</pubDate>
<dc:creator>Ryan Stephanus</dc:creator>
<guid>http://oracledelivery.wordpress.com/2009/10/07/crontab-file-location/</guid>
<description><![CDATA[With Linux, when issuing command like crontab-e   or    crontab -l,  in some case it is beneficial f]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>With Linux, when issuing command like crontab-e   or    crontab -l,  in some case it is beneficial for us if we had known their location.</p>
<p>well I tell just directly, they are located in /var/spool/cron  </p>
<p>those &#8220;crontab&#8221; files in /etc/cron* aren&#8217;t what I was looking for (it is not the same file as crontab -e)</p>
<p>In my case,  my  environment OS is under a VM machine and somehow, I don&#8217;t know why yet, each time I issued crontab -l   or crontab -e the CPU usage will go to 100% in 3 minutes right from a fresh boot.  I&#8217;ve tried to vi the file, but cpu becoming gradually unresponsive.. also,  I&#8217;ve tried to replace the file via FTP.  It still can&#8217;t be changed altough the file permission is 600 (I&#8217;m as root). </p>
<p>So,</p>
<p>1. I cat the file (the filename is the same as the user who created the file)</p>
<p>2. make a new file named root2, which I changed the content according to my needs</p>
<p>3. rm -rf root</p>
<p>4. mv root2 root</p>
<p>5. chmod 600 root</p>
<p> </p>
<p>Hope this post could be helpful under some circumstances..</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Cron در اوبونتو 9.10]]></title>
<link>http://free8beautifullife.wordpress.com/2009/11/18/cron-in-ubuntu-9-10/</link>
<pubDate>Wed, 18 Nov 2009 14:36:05 +0000</pubDate>
<dc:creator>iceage2098</dc:creator>
<guid>http://free8beautifullife.wordpress.com/2009/11/18/cron-in-ubuntu-9-10/</guid>
<description><![CDATA[Cron دایمونی (Daemonها مانند سرویس ها در سیستم عامل ویندوز است) است که برای زمان بندی کارها در گنو/ل]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://en.wikipedia.org/wiki/Cron" title="Cron">Cron</a> دایمونی (Daemonها مانند سرویس ها در سیستم عامل ویندوز است) است که برای زمان بندی کارها در <a href="http://fa.wikipedia.org/wiki/%DA%AF%D9%86%D9%88/%D9%84%DB%8C%D9%86%D9%88%DA%A9%D8%B3" title="گنو/لینوکس">گنو/لینوکس</a> استفاده می شود. هر کاربر در گنو/لینوکس دارای یک فایل به نام crontab است که دایمون Cron برنامه هایی که در فایل های crontab قرار دارند را بر اساس زمان بندی آن ها اجرا می کند.</p>
<p>برای ایجاد فایل crontab به راهنمای ویکی در <a href="http://wiki.ubuntu-ir.org/CronHowto" title="Cron Howto">این جا</a> مراجعه کنید.</p>
<p>برنامه هایی که شما می خواهید اجرا کنید به دو صورت هستند:</p>
<ol>
<li> برنامه هایی که دارای محیط گرافیکی کاربر هستند (<a href="http://en.wikipedia.org/wiki/GUI" title="GUI">GUI</a>) و نیاز به تعامل با <a href="http://en.wikipedia.org/wiki/X_server" title="X Window System">سرویس دهنده پنجره X</a> هستند مانند مرورگر <a href="http://en.wikipedia.org/wiki/Firefox" title="Firefox">Firefox</a></li>
<li>برنامه هایی که بدون GUI هستند که این برنامه ها خروجی و ورودی آن ها در پوسته خط فرمان است و برای اجرا شدن نیازی به تعامل با سرویس دهنده پنجره X ندارند. مانند برنامه <a href="http://en.wikipedia.org/wiki/Ls">ls</a> یا <a href="http://en.wikipedia.org/wiki/GNU_Privacy_Guard">GPG</a></li>
</ol>
<p>برنامه هایی که در دسته دوم قرار می گیرند بدون هیچ مشکلی به وسیله Cron اجرا می گردند. اما برنامه های دستهٔ اول که دارای GUI هستند فقط با نوشتن دستور مورد نظر اجرا نخواهند شد. قبل از دستور باید به سرویس دهنده X بگویید که برنامه در کدام صفحه نمایش برای شما اجرا شود. برای این منظور قبل از دستور مورد نظر از env DISPLAY=:0 استفاده می کنیم. به عنوان مثال برای اجرای برنامه gedit در ساعت 10:25 هر روز صبح در فایل crontab دستور زیر را وارد می کنیم:</p>
<p dir="ltr">25 10 * * * env DISPLAY=:0 /usr/bin/gedit</p>
<p dir="rtl">DISPLAY=:0 به Cron می گوید که برنامه در صفحه جاری (desktop) اجرا شود.</p>
<p dir="rtl">و اگر دارای چندین صفحه نمایش هستید از دستور زیر استفاده می کنیم:</p>
<p dir="ltr">25 10 * * * env DISPLAY=:0.0 /usr/bin/gedit</p>
<p dir="rtl">DISPLAY=:0.0 به Cron می گوید که برنامه در صفحه نمایش اول و در صفحه جاری اجرا شود.</p>
<p dir="rtl"><strong>توجه</strong>: در <a href="http://en.wikipedia.org/wiki/Ubuntu_9.10#Ubuntu_9.10_.28Karmic_Koala.29" title="Ubutu 9.10">اوبونتوی 9.10</a> (کارمیک) شما باید X ACL را برای localhost فعال کنید. برای این منظور از دستور زیر استفاده می کنیم:</p>
<p dir="ltr">xhost +local:</p>
<p dir="rtl">این دستور حتما باید قبل از اجرا شدن یک برنامه GUI به وسیله Cron اجرا شود. شما می توانید این دستور را در قسمت Startup Application قرار دهید تا هنگام بوت شدن سیستم اجرا شود.</p>
<p dir="rtl">=-=-=-=-=<br /><em>Powered by </em><a href="http://bilbo.gnufolks.org/"><strong><em>Bilbo Blogger</em></strong></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Cron Alarm Clock]]></title>
<link>http://bsriram.wordpress.com/2009/10/08/cron-alarm-clock/</link>
<pubDate>Thu, 08 Oct 2009 06:00:33 +0000</pubDate>
<dc:creator>Sri Ram</dc:creator>
<guid>http://bsriram.wordpress.com/2009/10/08/cron-alarm-clock/</guid>
<description><![CDATA[What is Cron? Cron enables users to schedule jobs (commands or shell scripts) to run automatically a]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>What is Cron?</strong></p>
<p>Cron enables users to schedule jobs (commands or shell scripts) to run automatically at a certain time or date. It is commonly used to perform system maintenance or administration, though its general purpose nature means that it can be used for other purposes, such as connecting to the Internet and downloading email.</p>
<p>Cron uses the crontab, <strong>a configuration</strong> file that specifies shell commands to run periodically on a given schedule.</p>
<p>Crontab has following options:</p>
<p>-l    list the crontab</p>
<p>-e    edit the crontab</p>
<p>-r    remove the crontab</p>
<p>The application “crontab” is used to create and edit cron jobs and the cron daemon checks for cronjobs a the top of every minute.</p>
<p>For example :</p>
<p><strong>crontab -e </strong></p>
<p>It opens the vi editor to enter the cron jobs.</p>
<p>It looks like</p>
<pre>#   minute (0-59),
#   &#124;   hour (0-23),
#   &#124;   &#124;   day of the month (1-31),
#   &#124;   &#124;   &#124;   month of the year (1-12),
#   &#124;   &#124;   &#124;   &#124;   day of the week (0-6 with 0=Sunday).
#   &#124;   &#124;   &#124;   &#124;   &#124;   commands
</pre>
<p>For Example:<br />
55 10 8 11 * echo &#8220;This runs at 10:55 on 8th November&#8221;</p>
<p>To list all cron jobs:</p>
<blockquote><p>
<strong>crontab -l</strong>
</p></blockquote>
<p>To remove a  cron job :</p>
<blockquote><p>
<strong>crontab -r</strong>
</p></blockquote>
<p>For alarm clock, A Command Line Mp3 player can be used here that is mpg321. you may use any mp3 player here but you have to specify what X display to play your player.</p>
<p>For Command Line Mp3 Player,</p>
<p><span style="background-color:#ffffff;"></p>
<blockquote>
<pre>30  04  *   *   * mpg321 "/home/sriram/Music/Alarm1.mp3"</pre>
</blockquote>
<p>&#160;</p>
<p>For Other Mp3 Player(Audacious):</p>
<blockquote>
<pre>30  04  *   *   * env DISPLAY=:0.0 audacious "/home/sriram/Music/Alarm1.mp3"</pre>
</blockquote>
<p>&#160;</p>
<p>The asterik can be used (*) to satisfy all variables.  I found some good alarm tracks at <a href="http://www.policeinterceptor.com/navysounds.htm" target="_blank">this site</a> the were perfect for the task</p>
<p>&#160;</p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
