Cache directories keep getting changed to root

I'm testing out elgg and have a problem I have not been able to solve.
I don't think it's the cron jobs because I've watched them run and don't see the owner changed. However, it might be one of those and I'm not catching it.

I can't seem to find what is causing this.

The directory in question is the cache dir, above the web root.
Sometimes the Files directory gets changed to root, most times it's something deeper inside the Files dir as shown.

# ls -la /var/www/dat/caches/fastcache/elgg_boot/Files/
total 4
drwxrwxr-x 3 apache apache  33 Aug 16 12:38 .
drwxr-x--- 3 apache apache  19 Aug 16 12:38 ..
drwxrwxr-x 3 apache apache  16 Aug 17 19:04 19
-rwxrwxr-x 1 apache apache 183 Aug 16 12:38 .htaccess

# ls -la /var/www/dat/caches/fastcache/elgg_boot/Files/19/
total 0
drwxrwxr-x 3 apache apache 16 Aug 17 19:04 .
drwxrwxr-x 3 apache apache 33 Aug 16 12:38 ..
drwxr-x--- 2 root   root   50 Aug 17 19:04 17

# ls -la /var/www/dat/caches/fastcache/elgg_boot/Files/19/17/
total 24
drwxr-x--- 2 root   root      50 Aug 17 19:04 .
drwxrwxr-x 3 apache apache    16 Aug 17 19:04 ..
-rw-r--r-- 1 root   root   20520 Aug 17 19:04 1917160df70d83043f81fc682c99dfa6.txt

  • This command

    chown -R apache:apache /var/www/dat/

    will fix it.

    Note: Any command via cron or elgg-cli run as root will change the ownership of this directory.

    For example, use this:

    su -s /bin/bash -c "php elgg-cli cache:invalidate" apache

    Cron tasks:

    crontab -u apache -e
  • Hi,

    That's interesting. I had actually initially created a new crontab using apache "

    crontab -u apache -e

    Something didn't work so I put it into the main root crontab but forgot to make it apache owned.

    Seems to be ok now so thank you for your help on this. Now to work through the next problems and questions in this interesting software.