D
D
deleted-mezhevikin2015-10-03 12:37:54
MAMP
deleted-mezhevikin, 2015-10-03 12:37:54

How to run scheduled commands in laravel as root?

There is a project on laravel5, in it, according to the schedule, a command is launched in Kernel.php that writes a file to the storage folder:

$schedule->call(function()
{
      \File::put(storage_path('test.txt'), 'tut text tut text tut text');

 })->everyMinute();

The problem is that the file is created redonly, if the same piece of code is called through the controller, then the file is created by the readwrite.
I run the command through macovsky launchd. Cron does not work in the latest versions of macos.
launchd code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.the-website.cron</string>
        <key>ProgramArguments</key>
        <array>
                <string>php</string>
                <string>/Users/name/Desktop/project/artisan</string>
                <string>schedule:run</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>StartInterval</key>
        <integer>60</integer>
</dict>
</plist>

I am using Mac OS 10.10.5. Mamp PRO 3.4
Making a storage folder 777 does not help, all subsequent files will still be saved as readonly
chmod -R 777 storage

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-10-03
Protko @Fesor

How about still solving the main problem - running php-cli from under the same user, from under which you have puff under the web.
And yes, running such things as root is bad.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question