<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MakeUseOf &#187; cron</title>
	<atom:link href="http://www.makeuseof.com/tags/cron/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.makeuseof.com</link>
	<description>Cool Websites, Software and Internet Tips</description>
	<lastBuildDate>Fri, 10 Feb 2012 21:31:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How To Set Up A Cron Job To Automate Your Domains &amp; Databases</title>
		<link>http://www.makeuseof.com/tag/cron-job/</link>
		<comments>http://www.makeuseof.com/tag/cron-job/#comments</comments>
		<pubDate>Thu, 23 Dec 2010 16:31:44 +0000</pubDate>
		<dc:creator>Jeffry Thurana</dc:creator>
				<category><![CDATA[How-To Articles]]></category>
		<category><![CDATA[automate]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[webmaster tools]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.makeuseof.com/?p=61219</guid>
		<description><![CDATA[In a very basic sense, the computer was created to make our life easier &#8211; to take repetitive tasks out of our hands so we can focus more on the creative side. Imagine what kind of Internet life we would have if the computer couldn&#8217;t &#8211; for example &#8211; detect and block unwanted malicious sites [...]]]></description>
			<content:encoded><![CDATA[<p><firstimage="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2010/12/cron.jpg"><img class="align-left" style="border: 0px none; margin-left: 20px; margin-top: 5px; float: right;" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2010/12/cron.jpg?323f2c" border="0" alt="cron job" width="240" height="122" />In a very basic sense, the computer was created to make our life easier &#8211; to take repetitive tasks out of our hands so we can focus more on the creative side. Imagine what kind of Internet life we would have if the computer couldn&#8217;t &#8211; for example &#8211; detect and block unwanted malicious sites automatically. Doing that manually on a regular basis would eat up our precious time so much that it would not be worth connecting to the Internet in the first place.</p>
<p>Automation is an inseparable part of the computer universe. We have different applications to do different kinds of automation on our computer.  On the server side, that automation agent is called Cron.</p>
<p><span id="more-61219"></span></p>
<h2>The Definition</h2>
<p>The first place that I&#8217;d go to find a definition would be Wikipedia. Here&#8217;s their explanation of <a href="http://en.wikipedia.org/wiki/Cron_job">Cron Job</a>:</p>
<blockquote><p><em>&#8220;Cron&#8221; is a time-based job scheduler in Unix-like computer operating systems. The name cron comes from the word &#8220;chronos&#8221;, Greek for &#8220;time&#8221;. Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates. It is commonly used to automate 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.</em></p></blockquote>
<p>If you manage your own website(s), or self-hosted blog, you will likely come across cron jobs at some point. But please note that not all webhosting accounts includes cron jobs. It depends on the plan that you subscribe to. If you want to try creating and running one yourself, you should contact your hosting company regarding this matter.</p>
<p>Cron jobs have served server admins for ages, but that doesn&#8217;t mean ordinary webmasters can&#8217;t use the tool. Here are several possible &#8211; humbler &#8211; usages of cron jobs :</p>
<ul>
<li>to regularly and automatically back up database(s).</li>
<li>to automatically deactivate expired accounts in membership sites.</li>
<li>to do regular web maintenance such as checking broken links.</li>
<li>to send regular newsletter emails.</li>
<li>to update your database with traffic summaries.</li>
<li>to send updates of your web status to your email.</li>
</ul>
<h2>How To Set Up Cron Jobs</h2>
<p>Before we start anything, please remember that different hosting companies have different ways to do cron jobs. The most common location of this feature is in the CPanel. But again, please consult your hosting company regarding this matter. The example below is done on my hosting&#8217;s CPanel.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2010/12/03a-Crontab-in-CPanel-1.png?323f2c" border="0" alt="cron job" width="580" height="390" /></p>
<p>Even though there might be some differences in the setup between webhosts, the basic settings of cron jobs are similar:</p>
<ul>
<li>defining what command to execute,</li>
<li>where to send the result,</li>
<li>and how often should the repetition be.</li>
</ul>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2010/12/03b-Add-Crontab.png?323f2c" border="0" alt="cron job definition" width="580" height="360" /></p>
<p>A cron job could execute either a simple one line Unix command like:</p>
<blockquote><p><em>echo &#8220;You can write anything here&#8221;</em></p></blockquote>
<p>Or a set of complex command lines. But if there is more than one line of command, everything should be compiled into a script and uploaded into a location on your web host. Then write down the path of the script in the &#8220;<em>Command to execute</em>&#8221; field. By writing down the file path, you are telling cron to run that script at the pre-determined time cycle.</p>
<p>It&#8217;s advisable to put your scripts <strong>above</strong> your web&#8217;s main directory so that they won&#8217;t be accessible in the browser. Create a new folder and save your scripts there. This is an important step to keep your scripts from the public eye.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2010/12/03d-Main-Directory.png?323f2c" border="0" alt="cron job definition" width="580" height="215" /></p>
<p>But some hosts restrict users from modifying this area. If this is the case, you can put the scripts within the main directory, but make sure that the location stays secret.</p>
<h2>Real-Life Examples</h2>
<p>Let&#8217;s look at some examples of setting up cron jobs. The first one is using a simple one line command to execute.</p>
<p>Step one is writing down the command. In this example, I use:</p>
<blockquote><p><em>echo &#8220;test&#8221;</em></p></blockquote>
<p>which tells cron to generate the text: &#8220;<em>test</em>&#8221; (sans quote) at regular intervals.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2010/12/09a-Cron-Test-1.jpg?323f2c" border="0" alt="cron jobs tutorial" width="430" height="245" /></p>
<p>I defined the email address where the generated text should be sent to, set the interval to 5 minutes, and clicked &#8220;<em>Add Crontab</em>&#8221; to activate it.</p>
<p>The result of this setup is that every 5 minutes I will get an email containing the word &#8220;test&#8221;.</p>
<p>Now let&#8217;s move to another less simple example. I want to set a system to backup my WordPress database automatically. Since I&#8217;m not good with scripting, I&#8217;ll just use a ready made WordPress database backup script available <a href="http://www.tamba2.org.uk/wordpress/cron/">here</a>.</p>
<p>I downloaded the script and uploaded it to my WordPress server using the online file manager within the CPanel.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2010/12/09b-Upload-File.jpg?323f2c" border="0" alt="cron jobs tutorial" width="470" height="140" /></p>
<p>Then I made a note about the path where this script is located. Since different hosting providers use different systems, you might see different settings. Please consult your hosting company about this file path.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2010/12/09c-Path.jpg?323f2c" border="0" alt="cron jobs tutorial" width="580" height="300" /></p>
<p>I wrote down the file path as the command to execute, set the interval every midnight twice a month, and clicked &#8220;<em>Add Crontab</em>&#8221; to activate it.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2010/12/09d-Add-Cron-Backup.jpg?323f2c" border="0" alt="cron job" width="420" height="220" /></p>
<p>These two examples demonstrate that setting up cron jobs is not as scary as many people imagine it.</p>
<p>Cron jobs might not be something that common internet users would often use. But knowing more about it and setting it up yourself might come in handy at a time when you have to automate a certain server-side task.</p>
<p>Have you ever set up a cron job for your websites? What was it for? Share your experiences using the comments below.</p>
<p><small>Image credit: <a rel="nofollow" href="http://www.flickr.com/photos/dreamsjung/4321012857/">dreamsjung</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.makeuseof.com/tag/cron-job/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>How To Run Linux Style Cron Jobs on Windows</title>
		<link>http://www.makeuseof.com/tag/bring-linux-cron-like-power-to-windows/</link>
		<comments>http://www.makeuseof.com/tag/bring-linux-cron-like-power-to-windows/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 23:01:06 +0000</pubDate>
		<dc:creator>Varun Kashyap</dc:creator>
				<category><![CDATA[Cool Windows Apps & Tricks]]></category>
		<category><![CDATA[How-To Articles]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[scheduled tasks]]></category>
		<category><![CDATA[windows tips]]></category>

		<guid isPermaLink="false">http://www.makeuseof.com/?p=11958</guid>
		<description><![CDATA[Ever wanted to connect/disconnect the Internet connection at particular times? Want to perform disk defragmentation on weekends when you are not working on your computer? Want to perform backups on 27th of each month? If you ever wondered how you could achieve that Linux style cron jobs on Windows and tried using the Windows task [...]]]></description>
			<content:encoded><![CDATA[<p><img style="margin-right:20px" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2009/02/logoimagetime.jpg?323f2c" border="0" alt="cron job windows" vspace="10" align="left" />Ever wanted to connect/disconnect the Internet connection at particular times?  Want to perform disk defragmentation on weekends when you are not working on your computer? Want to perform backups on 27th of each month?</p>
<p>If you ever wondered how you could achieve that Linux style cron jobs on Windows and tried using the Windows task scheduler you have probably given up hope and have multiple entries to run the same task. On the other hand if you have used the Linux Cron utility you&#8217;ll know the power it offers. Bringing similar powers and options to Windows is <strong>Z-Cron</strong>.</p>
<h2><strong>Download</strong></h2>
<p>You can download <a href="http://www.z-cron.com/scheduler.html">Z-Cron for free here</a>. The download is a zip file, extract and run the setup.</p>
<h2><strong>How to Use</strong></h2>
<p>Once Z-Cron has been set up, you can begin scheduling tasks with great power and ease. Lets say you keep all your torrent files in one directory and you want to be able to load all the torrent files in that directory in your torrent client for downloading, automatically at 2am on Saturdays and Tuesdays (for whatever reason, here in India we have some broadband plans where data transfer doesn&#8217;t count towards the bandwidth cap  between 2 am &#8211; 8 am, so you can use the following example and change it according to your needs).</p>
<p>Let&#8217;s walk through the process:</p>
<p><strong>1</strong>. I am using µtorrent in this example.  If you use any other torrent client you would have to find the command line options/parameters for your client. For µtorrent it is</p>
<p>µtorrent.exe /directory &#8220;&lt;torrent save path&gt;&#8221; &#8220;&lt;path to torrent file&gt;&#8221;</p>
<p><strong>2</strong>. Since we want to add all the torrents in a particular directory to the download queue you would have to create a batch file. I won&#8217;t get into the details here but here is what you add to the batch file (I am looping through all torrent files and adding them to µtorrent):</p>
<p><strong>ECHO OFF<br />
cd c:\Torrents<br />
FOR %%X IN (*.torrent) DO &#8220;C:\Program Files\µtorrent\µtorrent.exe&#8221; /directory &#8220;D:\Torrent_Downloads&#8221; c:\Torrents\%%X</strong></p>
<p>Where C:\Torrents is where I would store .torrent files and D:\Torrent_Downloads is where I want the downloads to be stored. Be careful while using spaces in names of folders or files, it may break the batch file code.</p>
<p><strong>3</strong>. Save this file as torrents.bat</p>
<p><strong>4</strong>. Start Z-Cron, Click on task (this allows you to create/edit existing tasks)</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2009/02/addtask.png?323f2c" alt="cron on windows xp" width="590" height="405" /></p>
<p><strong>5</strong>. This should open up the Job Settings Window like below. In here you can choose the program/batch file/commands to run and pass arguments to them. Since we already created a batch file in steps 1,2 and 3 we will choose that file here, name our task and provide some description.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2009/02/taskdesc.png?323f2c" alt="cron job windows " width="590" height="386" /></p>
<p><strong>6</strong>. Click on the scheduler tab and this is where you get the control over scheduling that you can&#8217;t even imagine to get with the default Windows Task Scheduler. The screen looks like this:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2009/02/scheduler.png?323f2c" alt="" width="590" height="386" /></p>
<p>You can choose to schedule tasks by weeks or months. Check the Weekday under &#8220;Period&#8221; and you will get the weekly scheduler. Check Tuesday and Saturday.</p>
<p>If however you want greater control you can schedule for specific dates by choosing &#8220;Month&#8221; as period, which makes it look like this:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2009/02/scheduler_month.png?323f2c" alt="" width="590" height="386" /></p>
<p>You can now do things like making the task run on 27th of every month, last Week of every month, or all Tuesdays of every month, or simply run on 27th February or any other day.</p>
<p><strong>7</strong>. So far so good, we have chosen the days we want the task to run, now for the time. Click on scheduler button to bring up a screen like the following:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2009/02/newschedule.png?323f2c" alt="" width="553" height="317" /></p>
<p>Hover over the check boxes and see the time change at the bottom, check the appropriate check box, you can select multiple checkboxes to run the task repeatedly.</p>
<p><strong>8</strong>. For our torrent download example the screens look like this (remember we want to run it at 2 am on Saturdays and Tuesdays)</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2009/02/torrent1.png?323f2c" alt="" width="590" height="386" /><br />
<img src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2009/02/newschedule.png?323f2c" alt="" width="553" height="317" /></p>
<p>That&#8217;s it we have scheduled the task to run at 2 am on Tuesdays and Saturdays (notice the calendar on right hand side).</p>
<p>In addition to the control you get in scheduling tasks, you can also use Z-Cron&#8217;s  built in commands to dial up your connection, move files/ directories, sound alarms, kill processes, monitor programs and many more things effectively removing tedious steps 1, 2 and 3. However if you need something custom, like the example above, you will have hack around a bit!</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2009/02/built_ins.png?323f2c" alt="zcron" width="590" height="419" /></p>
<p>So how do you like Z-Cron? Do you know of other similar utilities for Windows? Can you think of more constructive ways to use Z-Cron? Share with us in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.makeuseof.com/tag/bring-linux-cron-like-power-to-windows/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Schedule &amp; Automate Tasks In Linux With Gnome Schedule</title>
		<link>http://www.makeuseof.com/tag/schedule-and-automate-tasks-in-linux-with-gnome-schedule/</link>
		<comments>http://www.makeuseof.com/tag/schedule-and-automate-tasks-in-linux-with-gnome-schedule/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 19:01:27 +0000</pubDate>
		<dc:creator>Damien Oh</dc:creator>
				<category><![CDATA[Cool Linux Apps & Tips]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[Gnome]]></category>
		<category><![CDATA[scheduled tasks]]></category>

		<guid isPermaLink="false">http://www.makeuseof.com/?p=11640</guid>
		<description><![CDATA[Have you ever done a thing repeatedly on your computer and wished that you could automate it and get it to run on its own? In Linux, the easiest way to schedule and automate a task is to use the crontab. This is a command line based application that allows you to execute commands or [...]]]></description>
			<content:encoded><![CDATA[<p><img style="margin-right:20px" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2009/02/schedule-task.jpg?323f2c" border="0" alt="gnome scheduled tasks tool" vspace="10" align="left" />Have you ever done a thing repeatedly on your computer and wished that you could automate it and get it to run on its own?</p>
<p>In Linux, the easiest way to schedule and automate a task is to use the crontab. This is a command line based application that allows you to execute commands or scripts automatically at a specified time/date.</p>
<p>For those who dislike the terminal and command line interface, <a href="http://gnome-schedule.sourceforge.net/" target="_blank">Gnome Schedule</a> is the graphical equivalent of the crontab. It leverages the power of <a href="http://en.wikipedia.org/wiki/Cron" target="_blank">vixie-cron</a>, dcron and <a href="http://en.wikipedia.org/wiki/At_%28Unix%29" target="_blank">at</a> to manage your crontab file and provide an easy way to schedule tasks on your computer. Be it scheduling a recurrent task or task that happens only once, Gnome-schedule has no problem in handling it.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2009/02/gnome-schedule.jpg?323f2c" alt="gnome-schedule" /></p>
<h2><strong>Installation</strong></h2>
<p>Gnome Schedule is found in the repository of most Linux distros, so installation is an easy affair. If you are using Ubuntu, you can easily install it by clicking <a href="apt:gnome-schedule">this link</a>, in Synaptic Package Manager or in your terminal, type the following command:</p>
<p><em>sudo apt-get install gnome-schedule</em></p>
<h2><strong>Usage</strong></h2>
<p>When you schedule a new task, you can choose whether it is a recurrent task or just a one-time thing.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2009/02/gnome-schedule-newtask.jpg?323f2c" alt="task scheduler linux" /></p>
<p>For a one-time task, you will be prompted to enter the task description, the date and time of the code execution and the code to be executed. In case you don&#8217;t know, a one-time task doesn&#8217;t mean you can only schedule one thing to run. You can easily configure Gnome Schedule to run several commands and do different things all at the same time.</p>
<p>For example, you can get it to stop all the applications, clear the trash bin and shutdown the computer at 10pm sharp at night. You just need to ensure that you enter each command in a new line and in the sequence that you want it to run.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2009/02/gs-newtask1.jpg?323f2c" alt="gnome schedule newtask1" /></p>
<p>There is also a button for you to add the existing task as a template. With the template, you won&#8217;t have to enter the setting for the same task over and over again.</p>
<p>In the Recurrent mode, you can define the task to run every week, hour, minute, second, or at every reboot. If you want precise control, you can also turn on the Advanced mode to edit the schedule manually.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2009/02/gs-recurrent.jpg?323f2c" alt="gnome schedule recurrent mode" /></p>
<p style="text-align: center;"><img class="aligncenter" src="http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2009/02/gs-main.jpg?323f2c" alt="gnome schedule scheduled tasks" /></p>
<p>By default, Gnome Schedule is not able to run the command code that requires administrator permission. For scheduling tasks that involve the system setting, you need to first run Gnome Schedule in Super-user mode before you can add the task to the schedule. To do that, you have to run the Gnome Schedule application from the terminal.</p>
<p><em>gksu gnome-schedule</em></p>
<p>In the Super-user mode, you can also edit other user&#8217;s scheduled tasks.</p>
<h2><strong>Conclusion</strong></h2>
<p>Gnome Schedule is a simple and easy to use application for you to schedule and automate tasks in your Linux machine. It doesn&#8217;t require you to remember or learn any command line instruction for creating a cron job, yet it allows you to schedule and automate your tasks easily. One thing though, you will have to learn the command line codes that execute your tasks or you won&#8217;t be able to create the task.</p>
<p>It would be great if the developer can include some pre-defined template for the standard tasks such as shutdown, clear the trash, close all windows etc.</p>
<p>What other software do you use to automate and schedule tasks in your Linux machine?</p>
<p><small><strong>Image credit</strong>: <strong><a rel="nofollow" href="http://www.flickr.com/photos/jldupont/" target="_blank">Jean-Lou Dupont</a></strong></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.makeuseof.com/tag/schedule-and-automate-tasks-in-linux-with-gnome-schedule/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached (Requested URI is rejected)
Database Caching 1/17 queries in 0.021 seconds using apc
Object Caching 351/379 objects using disk: basic
Content Delivery Network via main.makeuseoflimited.netdna-cdn.com

Served from: www.makeuseof.com @ 2012-02-10 21:39:33 -->
