% CVSId: $Id: gl2.111.4.slides.tex,v 1.3 2003/10/25 04:26:21 anguslees Exp $
\documentclass[%
%draft,
%final,             %default
slideColor,
%slideBW,           %default
%total,             %default
%nototal,           %
%nocolorBG,         %default
colorBG,            %
%ps,                %default
pdf,                 %
%accumulate,        %
%noaccumulate,      %
%frames
%azure
%contemporain
%nuancegris
%troispoints
%lignesbleues
%darkblue 
%alienglow
%autumn  
%gyom  
ghr_gl2
]{prosper}

\usepackage{amsmath}
\usepackage{alltt}
\usepackage{moreverb}
\usepackage{pstricks,pst-node,pst-text,pst-3d}
\usepackage{thumbpdf}

\title{Linux Certification Study Group}
\subtitle{A set of \LaTeX\ presentations}
\author{\href{http://lcdp.sourceforge.net/}{{\green Angus Lees}}}
\email{gus@inodes.org}
\institution{%
  Granville College of TAFE\\
  Sydney, Australia}


%\DefaultTransition{% 
%Split
%Blinds
%Box
%Wipe
%Dissolve 
%Glitter
%Replace 
%} 

\newcommand{\heading}[1]{%
\framebox{\bf \normalsize \black \textrm{ {#1}}}
\par\vspace{2mm}
}

\newcommand{\cmd}[1]{%
\texttt{\$ #1 \(\hookleftarrow\)}
}

\newcommand{\rootcmd}[1]{%
\texttt{\# #1 \(\hookleftarrow\)}
}

\newcommand{\opt}[1]{%
{\bf\texttt{#1}}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\maketitle

%==============================================================================
%==============================================================================
%\begin{slide}{111.4 Automate system administration tasks by scheduling
%    jobs to run in the future [4]} 
%FIXME: why is '{}111.4' required?
\begin{slide}{{}111.4 Scheduling jobs [4]}
\thisthumb{thumb001.png}
\heading{Objective} \hypertarget{111.4}{ }

Candidate should be able to use \texttt{cron} or \texttt{anacron} to
run jobs at regular intervals and to use \texttt{at} to run jobs at a
specific time. Tasks include managing cron and at jobs and configuring
user access to cron and at services.

\normalsize \vfill \end{slide}

%==============================================================================
\begin{slide}{{}111.4 Scheduling jobs [4]}
\heading{Key files, terms and utilities}
 
\begin{minipage}[t]{40mm}
  \begin{description}
  \item \hyperlink{crontab}{\texttt{crontab}}
  \item \hyperlink{anacrontab}{\texttt{/etc/anacrontab}}
  \item \hyperlink{crontab}{\texttt{/etc/crontab}}
  \item \hyperlink{cron.allow}{\texttt{/etc/cron.allow}}
  \item \hyperlink{cron.deny}{\texttt{/etc/cron.deny}}
  \item \hyperlink{varspoolcron}{\texttt{/var/spool/cron/*}}
  \end{description}
\end{minipage}
%
\begin{minipage}[t]{40mm}
  \begin{description}
  \item \hyperlink{at}{\texttt{at}}
  \item \hyperlink{atq}{\texttt{atq}}
  \item \hyperlink{at.deny}{\texttt{/etc/at.deny}}
  \item \hyperlink{at.allow}{\texttt{/etc/at.allow}}
  \end{description}
\end{minipage}

\normalsize \vfill \end{slide} %---------------------------------------

%==============================================================================
%\overlays{7}{%
\begin{slide}{Basically}
%\hypertarget{}{ } %\heading{} 

  \vspace{2em}

  \begin{Itemize}

  \item \texttt{at} -- Run a command once

  \item \texttt{cron} -- Run a command periodically

  \end{Itemize}

\end{slide} %} %---------------------------------------

%==============================================================================
%\overlays{4}{%
\begin{slide}{The \texttt{at} command}
%\hypertarget{}{ } %\heading{} 

\texttt{at} takes a time and a list of commands to run. Any output to
\textsc{STDOUT} or \textsc{STDERR} will be mailed to the user running
\texttt{at}.

\vspace{1.8em}

\begin{alltt}
\cmd{at 2pm}\\
warning: commands will be executed using /bin/sh\\
at> date \(\hookleftarrow\)\\
at> ^D \(\hookleftarrow\)\\
job 3 at 2002-05-08 14:00
\end{alltt}

\end{slide} %---------------------------------------


%==============================================================================
%\overlays{4}{%
\begin{slide}{The \texttt{at} command}
%\hypertarget{}{ } %\heading{} 

\vspace{1.8em}

The current umask, working directory and environment (except for
\textsc{TERM}, \textsc{DISPLAY} and \textsc{\_}) are saved and restored
before running the job (unlike \texttt{cron}).

\vspace{1.8em}

The commands to run will be read from \textsc{STDIN} or from a file
given with \opt{-f}.

\normalsize \vfill \end{slide} %---------------------------------------


%==============================================================================
%\overlays{4}{%
\begin{slide}{Example \texttt{at} time specifications}
%\hypertarget{}{ } %\heading{} 

\texttt{at} allows a \emph{very} flexible time format.

\vspace{1.8em}

\begin{description}

\item[\texttt{17:36}] Run at 5:36pm today or tomorrow.

\item[\texttt{9pm May 8}] Run at 9pm on May 8th.

\item[\texttt{noon tomorrow}] Run at 12pm tomorrow.

\item[\texttt{now + 2 hours}] Run in 2 hours.

\end{description}

\vspace{1.8em}

See~\underline{at}(1) for more details.

\end{slide} %---------------------------------------


%==============================================================================
\overlays{2}{%
\begin{slide}{Queued jobs}
%\hypertarget{}{ } %\heading{} 

\texttt{atq} lists a user's pending jobs.

\begin{alltt}
\cmd{atq}\\
\rnode{A}{3}       2002-05-08 14:00 a gus
\end{alltt}

\vspace{1.8em}

\cmd{atrm \rnode{B}{3}} removes the queued job.

\vspace{1.8em}

\cmd{at -c \rnode{C}{3}} dumps the job on \textsc{STDOUT}.

\onlySlide*{2}{%
  \nccurve[linecolor=red,angleA=270,angleB=90]{->}{A}{B}
  \nccurve[linecolor=red,angleA=270,angleB=90]{->}{A}{C}
  }%

\end{slide} } %---------------------------------------



%==============================================================================
%\overlays{4}{%
\begin{slide}{\texttt{crontab}}
%\hypertarget{}{ } %\heading{} 

\texttt{cron} is a daemon that reads everyone's \texttt{crontab}
information, spawning new tasks at the appropriate times.

\begin{description}
\item[\texttt{crontab \textit{file}}]
  Replace your crontab file with \textit{file}.

\item[\texttt{crontab -l}]
  List your crontab.

\item[\texttt{crontab -r}]
  Remove your crontab.

\item[\texttt{crontab -e}]
  Edit your crontab (with \textsc{\$EDITOR}).

\end{description}

\end{slide} %---------------------------------------


%==============================================================================
\overlays{6}{%
\begin{slide}{\texttt{crontab} file format}
%\hypertarget{}{ } %\heading{} 

A sample \texttt{crontab} file:

\begin{alltt}
\rnode{min}{0} \rnode{hr}{7} \rnode{dom}{1} \rnode{mon}{jan} \rnode{wild}{*}\\
echo "sleep in, you dont feel so good"\\
\vspace{1em}
\rnode{comment}{\# gratuitous noise}\\
0 17 * * \rnode{dow}{mon,wed,fri}        \rnode{stdin}{wall\%meeting in 5 minutes\%}\\
\vspace{1em}
0 9-18\rnode{step}{/2} * * \rnode{range}{mon-fri}      \rnode{env}{\$HOME}/bin/cron.bihourly
\end{alltt}

\vspace{1.8em}

\onlySlide*{2}{%
\rnode{commentX}{Line based, hash comments, ignored blank lines, etc}
\nccurve[linecolor=red,angleA=270,angleB=90]{<-}{comment}{commentX}%
}

\onlySlide*{3}{%
\begin{Itemize}
\item \rnode{minX}{Minute (0-59)}
\item \rnode{hrX}{Hour (0-23)}
\end{Itemize}
\nccurve[linecolor=red,angleA=270,angleB=90]{<-}{min}{minX}%
\nccurve[linecolor=red,angleA=270,angleB=0]{<-}{hr}{hrX}%
}

\onlySlide*{4}{%
\begin{Itemize}
\item \rnode{domX}{Day of month (1-31)}
\item \rnode{monX}{Month (1-12 or jan-dec)}
\item \rnode{dowX}{Day of week (0-7 or sun-sat)}
\end{Itemize}
\nccurve[linecolor=red,angleA=270,angleB=180]{<-}{dom}{domX}%
\nccurve[linecolor=red,angleA=270,angleB=90]{<-}{mon}{monX}%
\nccurve[linecolor=red,angleA=270,angleB=0]{<-}{dow}{dowX}%
}

\onlySlide*{5}{%
\begin{Itemize}
\item \rnode{stepX}{Step}
\item \rnode{wildX}{Wildcard}
\item \rnode{rangeX}{Ranges}
\item \rnode{listX}{Lists}
\end{Itemize}
\nccurve[linecolor=red,angleA=270,angleB=0]{<-}{wild}{wildX}%
\nccurve[linecolor=red,angleA=270,angleB=0]{<-}{range}{rangeX}%
\nccurve[linecolor=red,angleA=270,angleB=0]{<-}{dow}{listX}%
\nccurve[linecolor=red,angleA=270,angleB=90]{<-}{step}{stepX}%
}

\onlySlide*{6}{%
See \underline{crontab}(5) for:
\begin{Itemize}
\item \rnode{envX}{Environment variables}
\item \rnode{stdinX}{Providing \textsc{STDIN}}
\end{Itemize}
\nccurve[linecolor=red,angleA=270,angleB=0]{<-}{env}{envX}%
\nccurve[linecolor=red,angleA=270,angleB=0]{<-}{stdin}{stdinX}%
}

\end{slide} } %---------------------------------------


%==============================================================================
%\overlays{4}{%
\begin{slide}{cron from root}
%\hypertarget{}{ } %\heading{} 
  
  A few extra issues arise when editing \texttt{/etc/crontab} (and
  similar ``system'' crontab files):

\begin{Itemize}
  
\item Don't use \texttt{crontab -e}, edit \texttt{/etc/crontab}
  directly.

\item A new column (after timespec, before command) gives the user
  to the command run as.

\item Distributions often create directories for ``common''
  frequencies. It usually makes much more sense to place a script in
  there, rather than adding your own crontab lines.
  
  Debian (for example) runs any scripts in
  \texttt{/etc/cron.\{daily,weekly,monthly\}} -- but these are
  triggered from normal entries in \texttt{/etc/crontab}, so there's
  no real mystery here.

\item \emph{(Debian specific?)} \texttt{/etc/cron.d/*} is read in
  addition to \texttt{/etc/crontab} (they also have the extra user
  field).

\end{Itemize}

\end{slide} %---------------------------------------


%==============================================================================
%\overlays{4}{%
\begin{slide}{\texttt{anacron}}
%\hypertarget{}{ } %\heading{} 

\vspace{1em}
  
Apparently some people turn their machines off.

\vspace{1em}

If your computer is always turned off at night (for example), then
daily jobs which are usually scheduled to run in the wee hours, will
never be run. This is a problem.

\vspace{1em}

\texttt{anacron} fixes this by running any missed jobs after a reboot
(or other times, like AC-on for laptops).

\end{slide} %---------------------------------------


%==============================================================================
%\overlays{4}{%
\begin{slide}{\texttt{anacron}}
%\hypertarget{}{ } %\heading{} 
  
\vspace{1em}

Since anacron can't use the crontab files, it has its own simplified
\texttt{/etc/anacrontab}.

\vspace{1em}

If you only use the standard
\texttt{/etc/cron.{daily,monthly,weekly}}, then no further
configuration will be necessary. Otherwise,
see~\underline{anacrontab}(5).

\vspace{1em}

\emph{Note that the frequency of anacron jobs can only be specified in days.}

\end{slide} %---------------------------------------


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

% LocalWords:  cron anacrontab crontab var umask sh EOT
