Note that cron scripts run in a limited environment, and give an
example for how to test scripts in such an environment. Approved by: hrs (mentor) Discussed with: dru
This commit is contained in:
parent
683ebbfaed
commit
34c32ef7ed
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=44805
1 changed files with 10 additions and 3 deletions
|
@ -362,9 +362,16 @@ PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
|
||||||
|
|
||||||
<tip>
|
<tip>
|
||||||
<para>Before using a custom script, make sure it is executable
|
<para>Before using a custom script, make sure it is executable
|
||||||
and test that it works as intended from the command line.
|
and test it with the limited set of environment variables set
|
||||||
This is especially important if the script includes any
|
by cron. To replicate the environment that would be used to
|
||||||
commands that deletes files using wildcards.</para>
|
run the above cron entry, use:</para>
|
||||||
|
|
||||||
|
<programlisting>env -i SHELL=/bin/sh PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin HOME=/home/<replaceable>dru</replaceable> LOGNAME=<replaceable>dru</replaceable> <replaceable>/usr/home/dru/bin/mycustomscript.sh</replaceable></programlisting>
|
||||||
|
|
||||||
|
<para>The environment set by cron is discussed in &man.crontab.5;.
|
||||||
|
Checking that scripts operate correctly in a cron environment
|
||||||
|
is especially important if they include any commands that delete
|
||||||
|
files using wildcards.</para>
|
||||||
</tip>
|
</tip>
|
||||||
|
|
||||||
<para>When finished editing the crontab, save the file. It
|
<para>When finished editing the crontab, save the file. It
|
||||||
|
|
Loading…
Reference in a new issue