Laravel task scheduler permission problem with cleanDirectory command












0















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.










share|improve this question




















  • 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 '18 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 '18 at 17:50













  • It doesn't give you some error when you execute the "php artisan schedule:run"?

    – Raúl Monge
    Nov 21 '18 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 '18 at 17:55


















0















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.










share|improve this question




















  • 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 '18 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 '18 at 17:50













  • It doesn't give you some error when you execute the "php artisan schedule:run"?

    – Raúl Monge
    Nov 21 '18 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 '18 at 17:55
















0












0








0








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 17:43







moonwalker

















asked Nov 21 '18 at 15:20









moonwalkermoonwalker

6721022




6721022








  • 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 '18 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 '18 at 17:50













  • It doesn't give you some error when you execute the "php artisan schedule:run"?

    – Raúl Monge
    Nov 21 '18 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 '18 at 17:55
















  • 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 '18 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 '18 at 17:50













  • It doesn't give you some error when you execute the "php artisan schedule:run"?

    – Raúl Monge
    Nov 21 '18 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 '18 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 '18 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 '18 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 '18 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 '18 at 17:50















It doesn't give you some error when you execute the "php artisan schedule:run"?

– Raúl Monge
Nov 21 '18 at 17:54







It doesn't give you some error when you execute the "php artisan schedule:run"?

– Raúl Monge
Nov 21 '18 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 '18 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 '18 at 17:55














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














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





















































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







Popular posts from this blog

How to send String Array data to Server using php in android

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Is anime1.com a legal site for watching anime?