Possible cron ownership issue

Possible cron ownership issue

by Dominic Myers -
Number of replies: 5

Hi,

I've got Moodle installed on Azure via a Bitnami image. All worked well except I kept getting issues logging in as an admin, but only every-so-often. After checking, it seemed as though there was an issue with access to the files within the moodledata folder. To fix it I run 

sudo chmod -R 777 moodledata/

And everything seems to work OK... for a while.

It seems to be mostly happening on Monday mornings, so I got to thinking about the cron jobs running. I also noticed that the owner of the trashdir changed to root.

Average of ratings: -
In reply to Dominic Myers

Re: Possible cron ownership issue

by James Steerpike -
Hard to know what Bitnami has set up. Problems in easy installs are hard to fix.
Setting permissions to 777 on a server is not usually a good solution.
There may be an easy solution but I would start again with a clean LAMP stack and a standard install and migrate my courses.
In reply to Dominic Myers

Re: Possible cron ownership issue

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
> the owner of the trashdir changed to root.

Not good. The owner should be the owner of the web server daemon. In plain Linux distributions (Fedora based or Debian based) it is either apache or www-data. See https://docs.moodle.org/en/Cron_with_Unix_or_Linux#Using_the_crontab_program_on_Unix.2FLinux. No idea of Azure or Bitnami though.
In reply to Visvanath Ratnaweera

Re: Possible cron ownership issue

by Dominic Myers -
Thanks, that's sort of what I thought too, though in this case, it's usually `daemon` who owns it. I think I'll have to run another cron job to reset the permission on a Monday morning or something. I think I read somewhere that there was a weekly cron job which tidied up that folder which isn't controlled by the usual PHP cron controller. I think it might be that cron job that's changing the permissions.
In reply to Dominic Myers

Re: Possible cron ownership issue

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Leaving the cron.php to its "usual owner" won't do. The link I gave earlier specifies # crontab -u www-data -e.

Running a second cron job to correct the mistakes of the first cron job sounds absurd to me. I would have corrected the permissions in moodledata manually (find /path/to/moodledata -type f -exec'... {} \;) and assign the cron.php to the owner of the web server process (apache, www-data or who ever).

> I read somewhere that there was a weekly cron job which tidied up that folder which isn't controlled by the usual PHP cron

Where?

To put it another way, you should be aware of all the crontabs of your system. Moodle on its own has no "timers". For recurring tasks, some external agent, typically cron, has to trigger a PHP file in its code.