Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Completely baffled as to why Cron job is not working



On 11/1/07, Darren Cook <darren@example.com> wrote:
> > Because the environment cron is running it in is different. ...
>
> My favourite way to get around this is to put something like this in
> your crontab:
> 16 8 * * * /bin/bash -c "cd /path/to/script/;php my_script.php"

Another way is to use full paths within your script, or to set up the
environment you need as part of the script.

Some things you can do to get a "feel" for how your script will run
under cron is to use the "env" command when running from the command
line. For example:

/usr/bin/env -i  /home/mythtv/myscript.sh

That will run your script in a "clean" environment. You can then watch
for errors and correct accordingly.

Also, when running a new cronjob you can do the following to log
stdout and stderr to a file:

0 13 * * * /home/mythtv/myscript.sh &> /home/mythtv/myscript.log

Then looking at /home/mythtv/myscript.log after a run will show you
the output of the script (standard and error).

Regards, Keith


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links