Giter Site home page Giter Site logo

Cron job is not working about docker-mautic HOT 11 CLOSED

mautic avatar mautic commented on July 18, 2024
Cron job is not working

from docker-mautic.

Comments (11)

luizeof avatar luizeof commented on July 18, 2024 2

@RammusXu

Mautic Docker uses crontab in the /etc/cron.d/ directory, so it does not appear in crontab -l.

It does not make much sense to run the commands as root because they can write the log and the www-data apache user can not read files created by root.

About the error:

Warning: fopen(/var/www/html/app/cache/prod/../run/sf.mautic-segments-update.5415eaf7823c0a036b252ba8a9f1f4065263e1c60a23cacf6b5851144245b8c9.lock): failed to open stream: Permission denied in /var/www/html/app/bundles/CoreBundle/Command/ModeratedCommand.php on line 150

Make sure the app / cache folder was created by root and set the property to www-data.

from docker-mautic.

jesseshieh avatar jesseshieh commented on July 18, 2024 1

I edited /etc/cron.d/mautic and commented out the line starting with @reboot and the jobs seem to be working for me now (except the @reboot command of course). I haven't dug into exactly why @reboot doesn't work, but here are some hints to investigate.
https://unix.stackexchange.com/questions/109804/crontabs-reboot-only-works-for-root

Also, I'm not sure if a reboot command makes sense for a docker container.

from docker-mautic.

RammusXu avatar RammusXu commented on July 18, 2024

@luizeof Do you have any ideas? Please help me.

from docker-mautic.

proffalken avatar proffalken commented on July 18, 2024

@RammusXu Please can you re-run the above commands, but this time when you get the permissions error, can you run ls -l against the file in the fopen() brackets and paste the input here?

from docker-mautic.

RammusXu avatar RammusXu commented on July 18, 2024
root@10e257dca355:/var/www/html/app/cache/run# ls -la /var/www/html/app/cache/prod/../run/sf.mautic-segments-update.5415eaf7823c0a036b252ba8a9f1f4065263e1c60a23cacf6b5851144245b8c9.lock
ls: cannot access '/var/www/html/app/cache/prod/../run/sf.mautic-segments-update.5415eaf7823c0a036b252ba8a9f1f4065263e1c60a23cacf6b5851144245b8c9.lock': No such file or directory

root@10e257dca355:/var/www/html/app/cache/run# ls -la
total 8
drwxr-xr-x 2 root     root     4096 Sep 18 09:32 .
drwxr-xr-x 5 www-data www-data 4096 Sep 12 10:34 ..

root@10e257dca355:/var/www/html/app/cache/run# ls -la  /var/www/html/app/bundles/CoreBundle/Command/ModeratedCommand.php
-rw-r--r-- 1 www-data www-data 6898 Jul 25 17:17 /var/www/html/app/bundles/CoreBundle/Command/ModeratedCommand.php

Is it clearly?

from docker-mautic.

proffalken avatar proffalken commented on July 18, 2024

hmmm, ok.

The offending code is https://github.com/mautic/mautic/blob/staging/app/bundles/CoreBundle/Command/ModeratedCommand.php#L150 so it's a case of tracking back where this is being called from and going from there

from docker-mautic.

t-l-k avatar t-l-k commented on July 18, 2024

@luizeof

Make sure the app / cache folder was created by root and set the property to www-data.

What does this mean, set the property to www-data?

Am also debugging this container now and /etc/cron.d/mautic does not appear to be running, despite cron service status reporting ok - nothing coming through on the fifo /var/log/cron.pipe.

Have checked cross referenced with Debian stretch cron documentation and it appears to be compliant. Will look in more detail tomorrow myself but ...

... has anyone progressed this at all? This image doesn't appear to have any syslogd enabled.

from docker-mautic.

t-l-k avatar t-l-k commented on July 18, 2024

Thanks @jesseshieh , I will try and follow suit. I'm not totally convinced my workstation is not mangling CRLF/LF correctly, but the Debian stretch cron documentation does say that cron is very fussy with the final line in the file and the presence of a LF vs an EOL, so that might be worth checking as well.

from docker-mautic.

t-l-k avatar t-l-k commented on July 18, 2024

I've just tried taking the mautic.crontab file, ensuring VSCode reports endings as LF, saved it and copied it into my image in a derived dockerfile overwriting the one from the published docker-mautic image, and it is now working. This is with the @reboot command enabled. I docker cp'd the files out from the original mautic/mautic image, and they're identical, line endings and all.

Digging a little deeper, the only difference I can see is the permissions applied to the file, essentially chmod 755?

Debian stretch docs say that 644 is an appropriate setting though:

cron.other files:

the files under these directories have to be pass some sanity checks including the following: be executable, be owned by root, not be writable by group or other and, if symlinks, point to files owned by root.

cron.d files, as above and:

Files in this directory have to be owned by root, do not need to be executable (they are configuration files, just like /etc/crontab) and must conform to the same naming convention as used by run-parts(8)

Working:

  File: /etc/cron.d/mautic
  Size: 1793            Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d      Inode: 1183275     Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2018-10-16 13:37:33.651217100 +0000
Modify: 2018-10-16 13:35:09.000000000 +0000
Change: 2018-10-16 13:35:34.063797300 +0000

Wasn't working:

  File: /etc/cron.d/mautic
  Size: 1793            Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d      Inode: 3160573     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2018-08-14 17:37:35.000000000 +0000
Modify: 2018-08-14 17:37:35.000000000 +0000
Change: 2018-09-13 14:38:41.453996500 +0000

Something seems inconsistent, perhaps it is an issue with the PHP base image.

from docker-mautic.

elwood218 avatar elwood218 commented on July 18, 2024

For me the cron was not working too but because of another reason. I have build my own Docker Image with Gitlab-CI and somehow the permissions at cloning of the repo changed to 666.
The cron-file is not allowed to have write-permission on group or other.
https://debian-administration.org/article/687/So_your_cronjob_did_not_run

So I have added this to my Dockerfile after the COPY of mautic.crontab and now it is working again:

# Ensure cron file has correct permissions
RUN chmod 644 /etc/cron.d/mautic

from docker-mautic.

mautibot avatar mautibot commented on July 18, 2024

This issue has been mentioned on Mautic Community Forums. There might be relevant details there:

https://forum.mautic.org/t/how-to-check-mautic-cron-jobs-inside-docker-container/19792/3

from docker-mautic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.