How to Setup Cron Job for a Shell Script in Magento 1.9

cronmagento-1.9shell

As it says in the title:

I have a script in shell that runs a report by using this command in CLI:

php /shell/myscript.php --profile 1

Now, i want to add it to crontab so it will be something like this:

0 * * * * /usr/bin/php -f PATH_TO_FILE/myscript.php --profile 1

But the above command is incorrect, and in the same time this is how magento works with this shell scripts, so i don't know how to proceed from here:

Any ideas?

Best Answer

The shell scripts often contain require 'abstract.php';, so they must be run within the shell directory itself. In that case, use a crontab like this:

0 * * * * cd /path/to/magento/shell && php myscript.php --whatever