Skip to content
Advertisement

Unable to run artisan command via cron in localhost [Laravel 8] [Solved] [closed]

I’m new with both laravel and crontab. I have a laravel 8 project and want to use cron to run the scheduled task. But i keep getting error. The task that i put in the cron tab is like this,

* * * * * /usr/local/bin/php /home/mydirectory/path/to/project/artisan schedule:run >> /tmp/laravel.log

But, when it is executed, the log give the following error.

Could not open input file: /home/mydirectory/path/to/project/artisan

I tried running the task in terminal/command line, and it is executed just fine. The weird thing is that i was able to run cron job task for my previous laravel project (the cron job task has been deleted though), but not for this project. I have use chmod 755 as well.

I’m really confused what is wrong with this one 🙁 Btw i’m using macos and laravel 8.83. Thanks for your help!

Advertisement

Answer

Turns out i haven’t give full disk access to cron 🙂

For mac users, you might try to give full disk access to cron so that it will be able to access users folder. To do so, go to Security and Privacy in System Preferences > find Full Disk Access in Privacy tab > drag “cron” file from “/usr/sbin/cron” in directory to Full Disk Access

Ref: https://osxdaily.com/2020/04/27/fix-cron-permissions-macos-full-disk-access/

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement