0

i have a php script which runs fine when executed by SSHing into my server and running it.

however the php script doesn't seem to run even though a cron job set to run it every 10 minutes.

How do I view errors produced by cron job ?

3 Answers 3

1

Remember that cron runs your script in a different working directory than what you're probably used to. Try something like the following on the command line:

cd /
./path/to/your/script.php

If it fails, modify all paths in your script correctly until it runs. Then it will run in cron.

Sign up to request clarification or add additional context in comments.

Comments

1

Sometimes, the error messages are emailed to you by cron. Otherwise, it probably gets sent to a hapless system administrator who probably scrupulously saves the messages in /dev/null.

When things work from the command line and do not work from cron, the 'environment' is almost always at fault. Something that is set in the normal command line environment is not set in the cron environment. Remember, cron does not run your profile for you - you have a bare minimal set of environment variables with bare minimum values for things like PATH.

Generally, I assume that I should run a shell script from cron, and that shell script is responsible for ensuring the correct environment is in place - and that errors are trapped and logged appropriately - before running the main part of the software.

Comments

0

not sure but it's probably credentials related. Schedule your task to run with your user ID and see if that doesn't clear it up. If so, you'll need to create a set of "batch" credentials that you can use to schedule tasks to run beneath.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.