0

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?

1
  • "But the above command is incorrect" - what error do you get? Jun 21, 2017 at 15:39

1 Answer 1

3

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
5
  • i tried the following: */10 * * * * cd /home/path/to/shell && php run_data_flow_profile.php --profile 26 but it's not working, no errors in /var/log/cron and the same command works if i put it manually in console/terminal. any ideas ?
    – Abude
    Jun 21, 2017 at 20:32
  • try /usr/bin/php (or whatever the path to your PHP binary is), the PATH environment variable might not be available. If that still does not work, I suspect a problem within your PHP script Jun 21, 2017 at 21:09
  • thanks fabian, i've tried also with the path to PHP bin but still doesn't work, if the script have some issues then it shouldn't be working manually also right ? any other ideas to try ?
    – Abude
    Jun 21, 2017 at 21:15
  • when i run with /usr/bin/php i get this: Error in argument 3, char 2: no argument for option -
    – Abude
    Jun 21, 2017 at 21:25
  • i was referring the wrong bin, thank you for help, worked like a charm!
    – Abude
    Jun 21, 2017 at 22:58

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.