Adding a command as cronjob

Hi,

I want to add a command to cronjob I edited crontab like so

0 9 * * * cd /opt/cakefolder && bin/cake users cron

When I paste the command in cli the command runs fine. But when the cron is executed at 9 o clock it seems to not work.

Any ideas?

I’m not a super Linux expert, but using && is a bit funky - can’t promise it’ll execute both commands, and in the correct order, or even in the same shell. Put it all into a bash script (then chmod +755) and run that .sh from crontab.

Also, that crontab may be running as a different user than your CLI, like as root, which may not behave so well.

I changed it to this for now

0 9 * * * cd /opt/cakefolder && ./bin/cake users cron >> /some/log/file 2>&1

will test again

Do you have an error message to see whats failing?

Failed to find a CLI version of PHP; falling back to system standard php executable
./bin/cake: 65: exec: php: not found

Ok I had to do the following to fix it:

0 9 * * * cd /opt/cakefolder && /path/to/php/bin/php ./bin/cake.php users cron >> /some/log/file 2>&1

you can add your php path in the bin/cake file

See this: app/cake