0

What is wrong with this cronjob?

* * * * * * php -f /Documents/Programs/WeeklyHours/weekly_hour.php

I have combed through the various cron questions on StackExchange and nothing is working. When I run php -f /Documents/Programs/WeeklyHours/weekly_hour.php in the terminal it works perfectly. I know the cron jobs are running because I am getting error mail. At the bottom of the error mail messages it is saying "/bin/sh: Applications: command not found." Any ideas on what I am doing wrong?

Thanks in advance.

3 Answers 3

4

You have one more * than required in your crontab entry

Try

0-59 * * * * php -f /Documents/Programs/WeeklyHours/weekly_hour.php

The 0-59 is so that it will run every minute

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

Comments

0

The cron job likely runs under a different user which does not have its PATH set up the same as you, so it cannot find the php executable. You are able to simply type php because your PATH variable is set up to include its parent directory; that is not necessarily true for all other users.

Explicitly specify the path to the executable, e.g. /usr/bin/php. To figure out which php you're using, type:

$ which php

1 Comment

which php outputs /usr/local/bin/php. I tried * * * * * * /usr/local/bin/php -f /Documents/Programs/WeeklyHours/weekly_hour.php and it still doesn't work.
0
 * * * * * * /usr/local/bin/php -f /Documents/Programs/WeeklyHours/weekly_hour.php >> /ww/xx.log 2>&1

You can view the log.

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.