Created
August 24, 2021 10:17
-
-
Save stiucsib86/6fb4c4927cd157c37b19942c835e3195 to your computer and use it in GitHub Desktop.
Changing User Permission when running Laravel Artisan Command or Scheduling Crontab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you are running into following error when running Laravel Artisan commands: | |
# The stream or file "/opt/bitnami/apps/{projects}/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied | |
# | |
# This is caused by the logs/cache files owned by "daemon" (or www-data) user. To resolve this, you can run the command under the correct user, e.g: | |
$ sudo -u daemon php artisan schedule:run | |
# Similarly, if you want to schedule cronjobs, you can also | |
$ crontab -e | |
# Then change the user before running Artisan Commands, e.g. : | |
* * * * * cd /opt/bitnami/apps/{projects}/ && sudo -u daemon /opt/bitnami/php/bin/php artisan schedule:run >> /home/bitnami/logs/cron.log 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment