Problem
After installing oss642a, the OpenServer 5 cron supplement, certain cron jobs are failing to run with email messages being sent to root reporting:
From cron Tue Apr 16 16:00:01 2002
Return-Path: cron
Received: (from cron@localhost) by elmer.uk.sco.com (8.8.8/SCO5) id QAA00643
for root; Tue, 16 Apr 2002 16:00:00 +0100 (BST)
Message-Id: <200204161500.QAA00643@elmer.uk.sco.com>
From: cron@elmer.uk.sco.com (Cron daemon)
X-Mailer: SCO OpenServer Mail Release 5.0
To: root
Date: Tue, 16 Apr 2002 16:00:00 BST
Status: RO/bin/sh: testscript: not found*************************************************
Cron: The previous message is the standard output
and standard error of one of your cron commands.where testscript is the name of the job called by cron. Prior to
installing oss642a the same job worked fine.The relevant crontab entry for this job may read something like this (taken from "crontab -l" output):
0,30 * * * * testscript > /tmp/testscript.log # Run the script called testscript
Solution
The supplement, oss642a, introduces a new /etc/default/cron file, which specifies these key lines (among others):
setenv SHELL=/bin/sh
setenv PATH=/bin:/usr/bin:/usr/lbin
# historic, insecure default path
# setenv PATH=.:/bin:/usr/bin:/usr/lbinWithin a user's crontab, each job inherits the $HOME environment
variable, but not $PATH; this is explicitly set by cron. Prior to
oss642a, $PATH was set to ".:/bin:/usr/bin:/usr/lbin". search
the local directory first ("."). However, there is a security risk
associated with not setting an explicit path like the. There is
potential for a script/binary of the same name to be run instead of
the real one.Therefore, oss642a has set the default $PATH for cron jobs to be
"/bin:/usr/bin:/usr/lbin" (excluding the local directory). The
pre-oss642a behavior of including the local directory can be
reinstated by commenting out the current "setenv PATH" entry and
uncommenting the other (historic) one. Cron must then be restarted
either by rebooting or running the following commands logged in as
root:/etc/init.d/cron stop
/usr/bin/sd cronGiven the security risk associated with this, a better solution would be to leave the $PATH setting as it is (not including the local directory) and set the crontab line to read "$HOME/testscript" instead of just "testscript"; this still allows the users home directories to be moved later without upsetting the crontab.
See also
man crontab(C); cron(C)ta115162, "What is SLS OSS642A, the Cron supplement?"ta115442, "Cron jobs don't run after installing OSS642A on a system in high security mode."