Aoe_Scheduler icon indicating copy to clipboard operation
Aoe_Scheduler copied to clipboard

Scheduler appears to be running as system user "apache". It should be running as "magento".

Open durzel opened this issue 8 years ago • 5 comments

Hi,

I've been using AOE Scheduler for a short while and it seems to have been working properly, but I'm unclear as to the correct way it should be configured.

Like a lot of installs my Magento install is owned by a local user (in my case "magento"), with group access as the web server "apache".

When I configure AOE_Scheduler to run as "apache" (i.e. "System user for cron" is set to "apache", the scheduler_cron.sh lines as listed in Setup Instructions are in the "apache" crontab) I get the error message - Scheduler appears to be running as system user "apache". It should be running as "magento" even though "System user for cron" IS apache, and the scheduler_cron.sh is in the "apache" user's crontab?

When I use user "magento" (in "System user for cron", scheduler_cron.sh lines in "magento"'s crontab) then I don't get the error message above, but I do seem to get periodic "Permission denied" errors in the error.log. It seems Magento creates cache and session files with user & group ownership of "apache", with 600 permissions. This means "magento" can't access these files, which would appear to be causing these errors - though I can't say definitively that it is AOE_Scheduler causing them.

Any thoughts? Thanks in advance.

durzel avatar Apr 07 '16 09:04 durzel

The cron jobs should run as the same user that your PHP processes are running. Generally this means if you are running apache then cron should run as Apache (www-data or httpd or whatever the OS uses). In some cases the web server runs a different user than PHP. You usually see this with nginx setups using php-fpm. Apache can also run php-fpm as well. So, the directions were written to work for most people, not everyone.

With what you've described you should be running your cron as apache. I say this because you've said that files created by magento get the apache user by default. That's a very clear indicator of what user cron should have. You want cron to run the same user fit the reason you've discovered, some files written by magento are only accessible by the file owner, not the group.

It sounds like that check is bugged since it's saying you are using the wrong user account when you are not. Please file that as a bug and switch back to using apache as the cron user.

LeeSaferite avatar Apr 11 '16 12:04 LeeSaferite

Well, I guess this qualifies as a bug, so no need to open a new one.

LeeSaferite avatar Apr 11 '16 12:04 LeeSaferite

Sorry yes I should've been explicit, Apache is running as the default user "apache", and I'm using mod_php. All files created by the webserver therefore are created as "apache" user, "apache" group.

For clarity - do you need me to do anything else regards this?

durzel avatar Apr 11 '16 13:04 durzel

@durzel No, I think this is good enough to address the issue. That's for the report.

LeeSaferite avatar Apr 11 '16 13:04 LeeSaferite

@durzel the Adminhtml controller should be comparing the value of Aoe_Scheduler_Helper_Data::getLastRunUser with the value of Aoe_Scheduler_Helper_data::getConfiguredUser() (strictly). The former is a core_variable entry which is stored every time a schedule is run, and the latter is read from configuration. Could you var_dump() both methods from a temporary script that you run from your browser for comparison?

In this case, if you have set the configured user as "magento" and you are running the scheduler from the system user "magento" crontab, there should not be a problem, but it's worth doing a little debugging to check.

Related: #258

robbieaverill avatar May 20 '16 01:05 robbieaverill