⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch40_13.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 40] 40.13 Adding crontab Entries </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:50:47Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch40_01.htm"TITLE="40. Delayed Execution"><LINKREL="prev"HREF="ch40_12.htm"TITLE="40.12 Periodic Program Execution: The cron Facility "><LINKREL="next"HREF="ch40_14.htm"TITLE="40.14 Including Standard Input Within a cron Entry "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch40_12.htm"TITLE="40.12 Periodic Program Execution: The cron Facility "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 40.12 Periodic Program Execution: The cron Facility "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 40<BR>Delayed Execution</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch40_14.htm"TITLE="40.14 Including Standard Input Within a cron Entry "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 40.14 Including Standard Input Within a cron Entry "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-5411">40.13 Adding crontab Entries </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-45187"></A><ACLASS="indexterm"NAME="AUTOID-45190"></A>Most recent versions of UNIX have aspecial command for maintaining the <EMCLASS="emphasis">crontab</EM> file.To create a new<EMCLASS="emphasis">crontab</EM> file, create a file containingthe desired <EMCLASS="emphasis">crontab</EM> entries.Then run the <EMCLASS="emphasis">crontab</EM> command to install the file in the<EMCLASS="emphasis">cron</EM> spool area. For example, if user <EMCLASS="emphasis">chavez</EM> executes thecommand below, the file <EMCLASS="emphasis">mycron</EM> will be installed as<EMCLASS="emphasis">/usr/spool/cron/crontabs/chavez</EM>:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>crontab mycron</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">If <EMCLASS="emphasis">chavez</EM> had previously installed <EMCLASS="emphasis">crontab</EM> entries, they will be<EMCLASS="emphasis">replaced</EM> by those in <EMCLASS="emphasis">mycron</EM>; thus, any current entries that<EMCLASS="emphasis">chavez</EM> wishes to keep must also be present in <EMCLASS="emphasis">mycron</EM>.</P><PCLASS="para">The <EMCLASS="emphasis">-l</EM> option to <EMCLASS="emphasis">crontab</EM> lists the current <EMCLASS="emphasis">crontab</EM> entries, andredirecting its output to a file will allow them to be captured and edited:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>crontab -l &gt;mycron</B></CODE>$ <CODECLASS="userinput"><B>vi mycron</B></CODE>$ <CODECLASS="userinput"><B>crontab mycron</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-45220"></A><ACLASS="indexterm"NAME="AUTOID-45223"></A>The <EMCLASS="emphasis">-r</EM> option will remove all current <EMCLASS="emphasis">crontab</EM> entries. Under SunOS,<EMCLASS="emphasis">crontab</EM> has an additional <EMCLASS="emphasis">-e</EM> option that lets you directly edityour current <EMCLASS="emphasis">crontab</EM> entries in a single step (see article<ACLASS="xref"HREF="ch40_15.htm"TITLE="crontab Script Makes crontab Editing Easier/Safer ">40.15</A>for a script like that).</P><PCLASS="para">On BSD-based UNIX implementations, there is no separate <EMCLASS="emphasis">crontab</EM>command, nor does each user get a personal <EMCLASS="emphasis">crontab</EM> file.BSDdoes distinguish between &quot;global&quot; <EMCLASS="emphasis">crontab</EM> entries (in<EMCLASS="emphasis">/usr/lib/crontab</EM>) and &quot;local&quot; entries (in<EMCLASS="emphasis">/usr/lib/crontab.local</EM>)-however, you have to edit these filesdirectly, which will probably require you to become superuser.It's agood idea to collect personal and site-specific <EMCLASS="emphasis">crontab</EM> entriesin the <EMCLASS="emphasis">crontab.local</EM> file.</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">AF</SPAN> <SPANCLASS="bibliomisc">from O'Reilly &amp; Associates' <CITECLASS="citetitle">Essential System Administration</CITE></SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch40_12.htm"TITLE="40.12 Periodic Program Execution: The cron Facility "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 40.12 Periodic Program Execution: The cron Facility "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch40_14.htm"TITLE="40.14 Including Standard Input Within a cron Entry "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 40.14 Including Standard Input Within a cron Entry "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">40.12 Periodic Program Execution: The cron Facility </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">40.14 Including Standard Input Within a cron Entry </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed &amp; awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -