website rev 26

Add cron and local.sh to Handbook (en)
author Paul Issot <paul@slitaz.org>
date Sat Apr 19 12:26:04 2008 +0100 (2008-04-19)
parents 796d31b08d96
children b6741591549b
files en/doc/handbook/system-admin.html
line diff
     1.1 --- a/en/doc/handbook/system-admin.html	Tue Apr 15 22:28:47 2008 +0100
     1.2 +++ b/en/doc/handbook/system-admin.html	Sat Apr 19 12:26:04 2008 +0100
     1.3 @@ -36,6 +36,8 @@
     1.4  	<li><a href="#locale">Language and keyboard.</a></li>
     1.5      <li><a href="#bash">Install the Bash shell.</a></li> 
     1.6      <li><a href="#time">Set the system time.</a></li>
     1.7 +    <li><a href="#cron">Execute scheduled commands.</a></li>
     1.8 +    <li><a href="#local.sh">Add commands at boot time.</a></li>
     1.9  </ul>
    1.10  
    1.11  <a name="devices"></a>
    1.12 @@ -187,6 +189,66 @@
    1.13   # hwclock -s --utc
    1.14  </pre>
    1.15  
    1.16 +<a name="cron"></a>
    1.17 +<h3>Execute scheduled commands</h3>
    1.18 +<p>
    1.19 +The daemon 'crond' allows you to run commands automatically at a scheduled specific date or time. This is very
    1.20 +useful for routine tasks such as system administration. The directory cron uses is  
    1.21 +<code>/var/spool/cron/crontabs</code>.
    1.22 +</p>
    1.23 +<p>
    1.24 +Each user of the system can have his/her own tasks, they are defined in the file: <code>/var/spool/cron/crontabs/user</code>.
    1.25 +The crontab utility allows you amongst other things, to list the tasks specific to the user. The syntax of the
    1.26 +files is as follows:
    1.27 +</p>
    1.28 +<pre class="script">mm hh dd MMM DDD command &gt; log
    1.29 +</pre>
    1.30 +<p>
    1.31 +We will create a file with root priviledges and test the daemon 'crond' with a task performed every minute -
    1.32 +writing the date to a file /tmp/crond.test. It should be noted that the utility has an option
    1.33 +<code>crontab</code> for editing cron file using 'vi', this is not provided by SliTaz. In it's place you can use
    1.34 +GNU nano (&lt;Ctrl+X&gt; to save &amp; exit):
    1.35 +</p>
    1.36 +<pre> # nano /var/spool/cron/crontabs/root
    1.37 +</pre>
    1.38 +<pre class="script">* * * * * date &gt;&gt; /tmp/crond.test
    1.39 +</pre>
    1.40 +<p>
    1.41 +Launch <code>crond</code> with the option <code>-b</code> (background),
    1.42 +configured via <code>/etc/daemons.conf</code> and using the startup script:
    1.43 +</p>
    1.44 +<pre> # /etc/init.d/crond start
    1.45 +</pre>
    1.46 +<p>
    1.47 +You can wait a few minutes and view the contents of the file: /tmp/crond.test... OK:
    1.48 +</p>
    1.49 +<pre> # cat /tmp/crond.test
    1.50 +</pre>
    1.51 +<p>
    1.52 +To stop or restart the daemon crond:
    1.53 +</p>
    1.54 +<pre> # /etc/init.d/crond stop
    1.55 + Or :
    1.56 + # /etc/init.d/crond restart
    1.57 +</pre>
    1.58 +<h4>Invoke the daemon crond on every boot</h4>
    1.59 +<p>
    1.60 +To launch the daemon 'crond' each time you boot the system, just add it to the variable <code>START_DAEMONS</code>
    1.61 +in the configuration file <code>/etc/rcS.conf</code>, either before or after the web server or SSH server.
    1.62 +</p>
    1.63 +
    1.64 +<a name="local.sh"></a>
    1.65 +<h3>Add commands to be executed at boot</h3>
    1.66 +<p>
    1.67 +During the boot process, various scripts are executed to configure services, such as the start of the 
    1.68 +web server, networking etc. On SliTaz there is a script <code>/etc/init.d/local.sh</code> which allows
    1.69 +you to add commands to be launched at system startup. You can also create new scripts in /etc/init.d,
    1.70 +their links in /etc/rc.scripts for shell scripts and use /etc/rc.d for links to the startup script daemon in
    1.71 +/etc/rcS.conf:
    1.72 +</p>
    1.73 +<pre> # nano /etc/init.d/local.sh
    1.74 +</pre>
    1.75 +
    1.76  <!-- End of content -->
    1.77  </div>
    1.78