I've setup my own Docker image for running Grav, but there's just one issue that I can't seem to figure out, and it is that the Web UI says that Cron isn't available, but yet it seems to be working just fine from what I can tell.
This is the warning that I'm trying to fix:
I have the crontab running under the nginx user, which seems to work just fine:
Using the CLI, I can verify that nginx
has the correct crontab:
And just to see if it would make a difference, I added it to the root user as well:
... But it still shows the same warning in the Web UI.
The CLI also shows that the backups are being run:
I'm not entirely sure what else I can do to see if I can get this warning fixed.
My Dockerfile:
FROM nginx:stable-alpine
LABEL maintainer="William Miceli <[email protected]>"
USER root
ARG GRAV_VERSION
# Install Dependencies Needed For Grav, With Optional Modules To Help With Performance
RUN apk update && apk add --no-cache \
dcron \
php7 \
php7-curl \
php7-dom \
php7-fpm \
php7-gd \
php7-json \
php7-mbstring \
php7-openssl \
php7-pecl-apcu \
php7-pecl-yaml \
php7-session \
php7-simplexml \
php7-xml \
php7-zip
# Configure NGINX For Grav
ADD https://raw.githubusercontent.com/getgrav/grav/c381bc83040e00c9a8ebe91ac3bda5fe0c217197/webserver-configs/nginx.conf /etc/nginx/conf.d/default.conf
RUN sed -i 's/root \/home\/USER\/www\/html/root \/var\/www/g' /etc/nginx/conf.d/default.conf \
&& sed -i 's/fastcgi_pass unix:\/var\/run\/php\/php7.2-fpm.sock;/fastcgi_pass unix:\/var\/run\/php-fpm.sock;/g' /etc/nginx/conf.d/default.conf \
&& sed -i 's/#listen 80;/listen 80;/g' /etc/nginx/conf.d/default.conf \
&& sed -i '23cuser = nginx' /etc/php7/php-fpm.d/www.conf \
&& sed -i '24cgroup = nginx' /etc/php7/php-fpm.d/www.conf \
&& sed -i '47clisten.owner = nginx' /etc/php7/php-fpm.d/www.conf \
&& sed -i '48clisten.group = nginx' /etc/php7/php-fpm.d/www.conf \
&& sed -i '49clisten.mode = 0660' /etc/php7/php-fpm.d/www.conf \
&& sed -i 's/listen = 127.0.0.1:9000/listen = \/var\/run\/php-fpm.sock/g' /etc/php7/php-fpm.d/www.conf
# Setup Cron
RUN (crontab -u nginx -l; echo "* * * * * cd /var/www;/usr/bin/php bin/grav scheduler 1>> /dev/null 2>&1") | crontab -u nginx -
# Prepare Grav Files
RUN mkdir -p /var/www /usr/src/grav/user \
&& apk add --no-cache ca-certificates \
&& apk add --no-cache --virtual .install-dependencies unzip wget \
&& wget -P /var/www https://github.com/getgrav/grav/releases/download/${GRAV_VERSION}/grav-admin-v${GRAV_VERSION}.zip \
&& unzip -q /var/www/grav-admin-v${GRAV_VERSION}.zip -d /var/www \
&& rm /var/www/grav-admin-v${GRAV_VERSION}.zip \
&& mv -v /var/www/grav-admin/* /var/www \
&& rm -rfv /var/www/grav-admin \
&& apk del .install-dependencies \
&& chown -R nginx:nginx /var/www \
&& mv -v /var/www/user/* /usr/src/grav/user
COPY /entrypoint.sh /
EXPOSE 80
CMD ["/bin/sh", "/entrypoint.sh"]
Thank you for your help!!
Also, small thing I happened to notice, but doesn't seem to make any difference:
CLI says to have as crontab:
(crontab -l; echo "* * * * * cd /var/www;/usr/bin/php7 bin/grav scheduler 1>> /dev/null 2>&1") | crontab -
Whereas Web UI says:
(crontab -l; echo "* * * * * cd /var/www;/usr/bin/php bin/grav scheduler 1>> /dev/null 2>&1") | crontab -
(One is /usr/bin/php7
, other is /usr/bin/php
)
Don't know if that would matter to anything, but figured I'd mention.
The first thing to check is what user the 'webserver' runs with compared to when you are in the terminal. If they are different users, you are going to have this problem. The webserver can only check the crontab of the user it's running as. Also, the PHP version is a 'best guess' the symfony process command makes when trying to determine which PHP binary to use. It's not smart enough to use a specific version like you seem to have setup (php7
).
Within my /etc/nginx/nginx.conf
I have:
So the webserver user seems to be nginx, which has the crontab set.
Anywhere I might be missing?
I'm also getting this on a Debian 10 install where I have my crontab running as root and webserver is www-data.
Most helpful comment
The first thing to check is what user the 'webserver' runs with compared to when you are in the terminal. If they are different users, you are going to have this problem. The webserver can only check the crontab of the user it's running as. Also, the PHP version is a 'best guess' the symfony process command makes when trying to determine which PHP binary to use. It's not smart enough to use a specific version like you seem to have setup (
php7
).