<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>MemberManual/UsingCron</title><revhistory><revision><revnumber>13</revnumber><date>2019-01-14 19:16:18</date><authorinitials>ClintonEbadi</authorinitials><revremark>no need to request cron permissions explicitly</revremark></revision><revision><revnumber>12</revnumber><date>2013-07-22 21:38:54</date><authorinitials>ClintonEbadi</authorinitials><revremark>remove references to mire, hyperlink to crontab man page, note how to remove</revremark></revision><revision><revnumber>11</revnumber><date>2013-01-14 09:22:36</date><authorinitials>ClintonEbadi</authorinitials><revremark>cat</revremark></revision><revision><revnumber>10</revnumber><date>2008-07-07 04:28:20</date><authorinitials>localhost</authorinitials><revremark>converted to 1.6 markup</revremark></revision><revision><revnumber>9</revnumber><date>2008-04-14 02:37:08</date><authorinitials>DavidCrawshaw</authorinitials><revremark>run-in-pagsh requires a name and a command</revremark></revision><revision><revnumber>8</revnumber><date>2007-12-15 17:28:41</date><authorinitials>AdamChlipala</authorinitials><revremark>members2 -&gt; members</revremark></revision><revision><revnumber>7</revnumber><date>2007-12-09 22:44:21</date><authorinitials>AdamChlipala</authorinitials><revremark>Requesting permission</revremark></revision><revision><revnumber>6</revnumber><date>2007-11-14 03:54:05</date><authorinitials>MichaelOlson</authorinitials></revision><revision><revnumber>5</revnumber><date>2007-11-14 03:53:40</date><authorinitials>MichaelOlson</authorinitials><revremark>Add explanation of example</revremark></revision><revision><revnumber>4</revnumber><date>2007-11-14 03:47:39</date><authorinitials>MichaelOlson</authorinitials><revremark>Add PATH tp cron example</revremark></revision><revision><revnumber>3</revnumber><date>2007-11-13 23:40:05</date><authorinitials>MichaelOlson</authorinitials><revremark>Add run-in-pagsh to the example</revremark></revision><revision><revnumber>2</revnumber><date>2007-10-28 02:09:48</date><authorinitials>MichaelOlson</authorinitials><revremark>Flesh out</revremark></revision><revision><revnumber>1</revnumber><date>2007-10-28 00:39:39</date><authorinitials>MichaelOlson</authorinitials><revremark>Outline</revremark></revision></revhistory></articleinfo><para>This page describes the basic use of cron on HCoop systems. </para><section><title>Prerequisites</title><para>It is very important that you read the <ulink url="https://wiki.hcoop.net/MemberManual/UsingCron/MemberManual/RunningUnattendedCommands#">Running Unattended Commands page</ulink> to understand the general idea of how to run unattended commands. </para></section><section><title>Making a cron configuration file</title><para>Cron needs a special configuration file to tell it how to operate.  It is suggested that this file be called <code>~/.crontab</code>, though it can have any name. </para><para>For an explanation of the format of this file, see the <ulink url="http://linux.die.net/man/1/crontab">crontab manual page</ulink> (or run <code>man crontab</code> on the shell server). </para></section><section><title>Managing your cron jobs</title><section><title>Activating your cron configuration</title><para>Once you are satisfied with your setup, run the following command to activate your changes, assuming that your configuration file is called <code>~/.crontab</code>: </para><screen><![CDATA[crontab ~/.crontab]]></screen></section><section><title>Disabling your cron jobs</title><para>Just run <code>crontab -r ~/.crontab</code> </para></section><section><title>Checking your cron configuration</title><para>Run <code>crontab -l</code> to display the jobs cron is running for you. </para></section></section><section><title>Examples</title><para>One convention for making scripts to run commands in their own PAG, as specified by the <ulink url="https://wiki.hcoop.net/MemberManual/UsingCron/MemberManual/RunningUnattendedCommands#">Running Unattended Commands page</ulink>, is to create the <code>~/scripts</code> directory, and place your scripts there.  Then, make a cron configuration file that looks something like this. </para><screen><![CDATA[PATH=/afs/hcoop.net/common/bin:/usr/local/bin:/usr/bin:/bin
]]><![CDATA[
09 0 * * 0   run-in-pagsh --fg clean-mail           ~/scripts/clean-mail
11 0 * * 0   run-in-pagsh --fg remove-tmp           ~/scripts/remove-tmp
12 0 * * 0   run-in-pagsh --fg weekly-comment-check ~/scripts/weekly-comment-check
*/10 * * * * run-in-pagsh --fg make-git-projects    ~/scripts/make-git-projects]]></screen><para>The PATH line is needed so that you have access to <code>run-in-pagsh</code>.  Make sure you don't try to reference any other environment variables like <code>$HOME</code>, because cron will not expand them properly. </para><para>The first cron command runs something 9 minutes after midnight (aka the &quot;0th&quot; hour), every day of the month, every month, provided that it is Sunday (aka the &quot;0th&quot; day of the week).  In short: run something at 12:09 every Sunday. </para><para>The second and third commands are similar. </para><para>The fourth command runs something every 10 minutes. </para><!--rule (<hr>) is not applicable to DocBook--><para> <ulink url="https://wiki.hcoop.net/MemberManual/UsingCron/CategoryMemberManual#">CategoryMemberManual</ulink> </para></section></article>