[Techtalk] A PHP script in a crontab.

Telsa Gwynne hobbit at aloss.ukuu.org.uk
Sat Jan 29 21:30:39 EST 2005


On Sat, Jan 29, 2005 at 05:55:38PM +1100 or thereabouts, Sue Stones wrote:
> 
> Sorry I must have forgotten to say that the script works when I run it 
> manually, its just the running it from the CRON tab that doesn't work. 
> (thats why I didn't post any code).

When cron is being picky about whether to run, I always wonder
about the path and about the shell. I know there can be problems
with those. I just don't understand them! So man 5 crontab says,

  Several  environment variables are set up automatically by the cron(8)
  daemon.  SHELL is set to /bin/sh, and LOGNAME and HOME  are  set  from
  the  /etc/passwd  line  of the crontab’s owner.  HOME and SHELL may be
  overridden by settings in the crontab; LOGNAME may not.

Somewhere under INVOCATION in the man page for bash are details 
about interactive and non-interactive shells, which start-up files 
they read and don't read, and so on: 

  An  interactive  shell is one started without non-option arguments and
  without the -c option whose standard input and  error  are  both  con-
  nected  to terminals (as determined by isatty(3)), or one started with
  the -i option.  PS1 is set and $- includes i if bash  is  interactive,
  allowing a shell script or a startup file to test this state.

  [snip snip]
               A non-interactive shell invoked with the name sh does not
  attempt to read any other startup files.  When  invoked  as  sh,  bash
  enters posix mode after the startup files are read.

  [snipped lots more: it's a very large man page...]

Perhaps something needed by your script is only present in interactive
shells? A relative path, a complete path, something else? 

Telsa



More information about the Techtalk mailing list