I want to add a Laravel task into cron, this is what I use to run it from command line (and runs succesfully)
php artisan cron:hourly --env=staging
Translated into cron:
/usr/bin/php -q /home/usr/public_html/staging/artisan cron:hourly --env=staging
I assume there is a problem with the parameter --env=staging
because I got an error when the cron is executed (without this parameter I can't run the task in staging environment):
Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user ''@'localhost'
Could anyone explain me the the right syntax to execute the laravel task in cron?
Update
Actually, the problem is only happening if I place the cron command inside an SH script. Due to unknown reason, the script does not send "--env=staging" argument, and this ends on the error described.