Laravel task scheduler permission problem with cleanDirectory command
up vote
0
down vote
favorite
I've set up a console command with a handle() function like this:
public function handle()
{
$fileSystem = new Filesystem;
$fileSystem->cleanDirectory('storage/app/public/tmp');
}
And in the console kernel I set up the command:
$schedule->command('cleanupfiles:tmp')
->everyMinute()
->sendOutputTo(storage_path('logs/taskoutput.log'));
The superuser's crontab has the following entry:
* * * * * php /var/www/website/artisan schedule:run >> /dev/null 2>&1
I can see the task scheduler getting executed every minute by looking at the /var/log/syslog, so cron does it's job, but the folder contents are not cleaned. When I run the task directly on the terminal by: php artisan schedule:run I have the same effect; no files are deleted. Finally when I run the schedule with sudo php artisan schedule:run I see it works, files get deleted and output is written to taskoutput.log.
How can I solve this so the task runs with necessary permissions? Or is there anything else I miss here? Thanks.
laravel-5 cron schedule artisan
add a comment |
up vote
0
down vote
favorite
I've set up a console command with a handle() function like this:
public function handle()
{
$fileSystem = new Filesystem;
$fileSystem->cleanDirectory('storage/app/public/tmp');
}
And in the console kernel I set up the command:
$schedule->command('cleanupfiles:tmp')
->everyMinute()
->sendOutputTo(storage_path('logs/taskoutput.log'));
The superuser's crontab has the following entry:
* * * * * php /var/www/website/artisan schedule:run >> /dev/null 2>&1
I can see the task scheduler getting executed every minute by looking at the /var/log/syslog, so cron does it's job, but the folder contents are not cleaned. When I run the task directly on the terminal by: php artisan schedule:run I have the same effect; no files are deleted. Finally when I run the schedule with sudo php artisan schedule:run I see it works, files get deleted and output is written to taskoutput.log.
How can I solve this so the task runs with necessary permissions? Or is there anything else I miss here? Thanks.
laravel-5 cron schedule artisan
1
You can try giving permissions to the user "www-data" or the user that you are using to the storage directory sudo chown -R www-data:www-data /path/to/your/project/storage stackoverflow.com/questions/30639174/…
– Raúl Monge
Nov 21 at 17:43
the foldertmpis owned by www-data and it has write permissions to that folder. The upper folders such asstorageon the other hand is owned by me (not root) and www-data group and we both have write permissions. Do I need execute permission for www-data ontmpdirectory to delete files?
– moonwalker
Nov 21 at 17:50
It doesn't give you some error when you execute the "php artisan schedule:run"?
– Raúl Monge
Nov 21 at 17:54
Yes no errors there. Just says the command is due and executes it as everything is fine. And the log filetaskoutput.logis empty.
– moonwalker
Nov 21 at 17:55
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I've set up a console command with a handle() function like this:
public function handle()
{
$fileSystem = new Filesystem;
$fileSystem->cleanDirectory('storage/app/public/tmp');
}
And in the console kernel I set up the command:
$schedule->command('cleanupfiles:tmp')
->everyMinute()
->sendOutputTo(storage_path('logs/taskoutput.log'));
The superuser's crontab has the following entry:
* * * * * php /var/www/website/artisan schedule:run >> /dev/null 2>&1
I can see the task scheduler getting executed every minute by looking at the /var/log/syslog, so cron does it's job, but the folder contents are not cleaned. When I run the task directly on the terminal by: php artisan schedule:run I have the same effect; no files are deleted. Finally when I run the schedule with sudo php artisan schedule:run I see it works, files get deleted and output is written to taskoutput.log.
How can I solve this so the task runs with necessary permissions? Or is there anything else I miss here? Thanks.
laravel-5 cron schedule artisan
I've set up a console command with a handle() function like this:
public function handle()
{
$fileSystem = new Filesystem;
$fileSystem->cleanDirectory('storage/app/public/tmp');
}
And in the console kernel I set up the command:
$schedule->command('cleanupfiles:tmp')
->everyMinute()
->sendOutputTo(storage_path('logs/taskoutput.log'));
The superuser's crontab has the following entry:
* * * * * php /var/www/website/artisan schedule:run >> /dev/null 2>&1
I can see the task scheduler getting executed every minute by looking at the /var/log/syslog, so cron does it's job, but the folder contents are not cleaned. When I run the task directly on the terminal by: php artisan schedule:run I have the same effect; no files are deleted. Finally when I run the schedule with sudo php artisan schedule:run I see it works, files get deleted and output is written to taskoutput.log.
How can I solve this so the task runs with necessary permissions? Or is there anything else I miss here? Thanks.
laravel-5 cron schedule artisan
laravel-5 cron schedule artisan
edited Nov 21 at 17:43
asked Nov 21 at 15:20
moonwalker
644920
644920
1
You can try giving permissions to the user "www-data" or the user that you are using to the storage directory sudo chown -R www-data:www-data /path/to/your/project/storage stackoverflow.com/questions/30639174/…
– Raúl Monge
Nov 21 at 17:43
the foldertmpis owned by www-data and it has write permissions to that folder. The upper folders such asstorageon the other hand is owned by me (not root) and www-data group and we both have write permissions. Do I need execute permission for www-data ontmpdirectory to delete files?
– moonwalker
Nov 21 at 17:50
It doesn't give you some error when you execute the "php artisan schedule:run"?
– Raúl Monge
Nov 21 at 17:54
Yes no errors there. Just says the command is due and executes it as everything is fine. And the log filetaskoutput.logis empty.
– moonwalker
Nov 21 at 17:55
add a comment |
1
You can try giving permissions to the user "www-data" or the user that you are using to the storage directory sudo chown -R www-data:www-data /path/to/your/project/storage stackoverflow.com/questions/30639174/…
– Raúl Monge
Nov 21 at 17:43
the foldertmpis owned by www-data and it has write permissions to that folder. The upper folders such asstorageon the other hand is owned by me (not root) and www-data group and we both have write permissions. Do I need execute permission for www-data ontmpdirectory to delete files?
– moonwalker
Nov 21 at 17:50
It doesn't give you some error when you execute the "php artisan schedule:run"?
– Raúl Monge
Nov 21 at 17:54
Yes no errors there. Just says the command is due and executes it as everything is fine. And the log filetaskoutput.logis empty.
– moonwalker
Nov 21 at 17:55
1
1
You can try giving permissions to the user "www-data" or the user that you are using to the storage directory sudo chown -R www-data:www-data /path/to/your/project/storage stackoverflow.com/questions/30639174/…
– Raúl Monge
Nov 21 at 17:43
You can try giving permissions to the user "www-data" or the user that you are using to the storage directory sudo chown -R www-data:www-data /path/to/your/project/storage stackoverflow.com/questions/30639174/…
– Raúl Monge
Nov 21 at 17:43
the folder
tmp is owned by www-data and it has write permissions to that folder. The upper folders such as storage on the other hand is owned by me (not root) and www-data group and we both have write permissions. Do I need execute permission for www-data on tmp directory to delete files?– moonwalker
Nov 21 at 17:50
the folder
tmp is owned by www-data and it has write permissions to that folder. The upper folders such as storage on the other hand is owned by me (not root) and www-data group and we both have write permissions. Do I need execute permission for www-data on tmp directory to delete files?– moonwalker
Nov 21 at 17:50
It doesn't give you some error when you execute the "php artisan schedule:run"?
– Raúl Monge
Nov 21 at 17:54
It doesn't give you some error when you execute the "php artisan schedule:run"?
– Raúl Monge
Nov 21 at 17:54
Yes no errors there. Just says the command is due and executes it as everything is fine. And the log file
taskoutput.log is empty.– moonwalker
Nov 21 at 17:55
Yes no errors there. Just says the command is due and executes it as everything is fine. And the log file
taskoutput.log is empty.– moonwalker
Nov 21 at 17:55
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415222%2flaravel-task-scheduler-permission-problem-with-cleandirectory-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You can try giving permissions to the user "www-data" or the user that you are using to the storage directory sudo chown -R www-data:www-data /path/to/your/project/storage stackoverflow.com/questions/30639174/…
– Raúl Monge
Nov 21 at 17:43
the folder
tmpis owned by www-data and it has write permissions to that folder. The upper folders such asstorageon the other hand is owned by me (not root) and www-data group and we both have write permissions. Do I need execute permission for www-data ontmpdirectory to delete files?– moonwalker
Nov 21 at 17:50
It doesn't give you some error when you execute the "php artisan schedule:run"?
– Raúl Monge
Nov 21 at 17:54
Yes no errors there. Just says the command is due and executes it as everything is fine. And the log file
taskoutput.logis empty.– moonwalker
Nov 21 at 17:55