Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Laravel Commands with www-data user

I made a command in Laravel 5.1 that is supposed to delete some directories from the file system.

in the handle() method of the command class, i did shell_exec("whoami") and it returns raheel. However the user raheel has no permission on the specified directory. I want to run this command as apache www-data user.

How can i implement this in Laravel ?

Thanks

like image 770
Raheel Avatar asked Mar 16 '16 12:03

Raheel


1 Answers

This is how I'm running my crons:

su -c "php artisan schedule:run >> /dev/null 2>&1" -s /bin/sh www-data
like image 104
alepeino Avatar answered Sep 20 '22 12:09

alepeino