Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cron task seems not work #132

Closed
quentingosset opened this issue Aug 25, 2024 · 14 comments
Closed

Cron task seems not work #132

quentingosset opened this issue Aug 25, 2024 · 14 comments

Comments

@quentingosset
Copy link

Hello, I followed your documentation (https://hub.docker.com/r/shinsenter/php#other-system-settings) on crontask, but it doesn't seem to work properly.

I have enabled the crontab on my docker-compose :

environment:
      ENABLE_CRONTAB: 1

I have not yet added any crontask in etc/crontab.d and I get the error :

crond: can't lock /var/run/crond.pid, otherpid may be 280: Resource temporarily unavailable
run-parts: /etc/hooks/bootstrap/50-crontabs exited with return code 1

When i try to add my crontask "* * * * * /usr/local/bin/php -q /var/www/html/artisan schedule:run 2>&1" on the folder etc/crontab.d this cron is never executed.

Do you have a idea ?

If you find my Docker images useful, consider donating via PayPal:
 -> https://www.paypal.me/shinsenter
(To edit this welcome message, add your text to /etc/welcome.txt)
---------------
Container     : shinsenter/php (built: 2024-08-22T15:17:38+0000)
Distro        : Debian GNU/Linux 12 (bookworm)
Timezone      : UTC (GMT+0000)
UID / GID     : www-data:www-data (33:33)
App Root      : /var/www/html
Document Root : /var/www/html
---------------
Docker Images by SHIN Company
Copyright (C) 2024 SHIN Company <[email protected]>
This software is free under the GNU General Public License (GPL).
You can redistribute and/or modify it under the terms of the GNU GPL.
This program is provided with the hope that it will be useful,
but it comes WITHOUT ANY WARRANTY. For more details, refer to the GNU GPL.
To get support, please contact: SHIN Company <[email protected]>
Docker Hub:      https://hub.docker.com/u/shinsenter
GitHub Packages: https://github.com/shinsenter?tab=packages
PHP 8.3.10 (fpm-fcgi) (built: Aug 13 2024 01:36:32)
Copyright (c) The PHP Group
Zend Engine v4.3.10, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.10, Copyright (c), by Zend Technologies
Composer version 2.7.8 2024-08-22 15:28:36
crond: can't lock /var/run/crond.pid, otherpid may be 280: Resource temporarily unavailable
run-parts: /etc/hooks/bootstrap/50-crontabs exited with return code 1
[25-Aug-2024 16:47:04] NOTICE: fpm is running, pid 1
[25-Aug-2024 16:47:04] NOTICE: ready to handle connections
@shinsenter
Copy link
Owner

@quentingosset

I can't reproduce the issue you're experiencing. Could you provide more specific details so that I can try to replicate your problem?

It seems like you're trying to run a Laravel project.
If that's the case, you might want to try using Docker images for Laravel.
https://hub.docker.com/r/shinsenter/laravel

Best regards

@shinsenter
Copy link
Owner

Hi @quentingosset

Could you help me try pulling the latest Docker images and give it another shot?

@quentingosset
Copy link
Author

With your latest version I no longer get the error :

crond: can't lock /var/run/crond.pid, otherpid may be 280: Resource temporarily unavailable
run-parts: /etc/hooks/bootstrap/50-crontabs exited with return code 1

Thanks for your fix :)

@quentingosset
Copy link
Author

quentingosset commented Sep 30, 2024

@shinsenter mhmm strange after a crash of my docker and a reboot on the version php-fpm 8.4 i got this error :

/usr/local/include/php/ext/pcre/php_pcre.h:52:14: note: declared here
52 | PHPAPI void  php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str, zval *return_value,
|              ^~~~~~~~~~~~~~~~~~~
make: *** [Makefile:204: php_imap.lo] Error 1
ERROR: `make -j8' failed
Remove comerr-dev krb5-multidev libc-client2007e-dev libgssrpc4 libkadm5clnt-mit12 libkadm5srv-mit12 libkdb5-10 libkrb5-dev libpam0g-dev libssl-dev
Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
  comerr-dev* krb5-multidev* libc-client2007e-dev* libgssrpc4*
  libkadm5clnt-mit12* libkadm5srv-mit12* libkdb5-10* libkrb5-dev*
  libpam0g-dev* libssl-dev*
0 upgraded, 0 newly installed, 10 to remove and 0 not upgraded.
After this operation, 16.9 MB disk space will be freed.
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 14681 files and directories currently installed.)
Removing libc-client2007e-dev (8:2007f~dfsg-7+b2) ...
Removing libkrb5-dev:amd64 (1.20.1-2+deb12u2) ...
Removing krb5-multidev:amd64 (1.20.1-2+deb12u2) ...
Removing comerr-dev:amd64 (2.1-1.47.0-2) ...
Removing libkadm5srv-mit12:amd64 (1.20.1-2+deb12u2) ...
Removing libkdb5-10:amd64 (1.20.1-2+deb12u2) ...
Removing libkadm5clnt-mit12:amd64 (1.20.1-2+deb12u2) ...
Removing libgssrpc4:amd64 (1.20.1-2+deb12u2) ...
Removing libpam0g-dev:amd64 (1.5.2-6+deb12u1) ...
Removing libssl-dev:amd64 (3.0.14-1~deb12u2) ...
Processing triggers for libc-bin (2.36-9+deb12u8) ...
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 14178 files and directories currently installed.)
Purging configuration files for comerr-dev:amd64 (2.1-1.47.0-2) ...
Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
░█▀▀░█░█░▀█▀░█▀█░█▀▀░█▀▀░█▀█░▀█▀░█▀▀░█▀▄░░░█░█▀█░█░█░█▀█
░▀▀█░█▀█░░█░░█░█░▀▀█░█▀▀░█░█░░█░░█▀▀░█▀▄░▄▀░░█▀▀░█▀█░█▀▀
░▀▀▀░▀░▀░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀░▀░░▀░░▀▀▀░▀░▀░▀░░░▀░░░▀░▀░▀░░
If you find my Docker images useful, consider donating via PayPal:
 -> https://www.paypal.me/shinsenter
(To edit this welcome message, add your text to /etc/welcome.txt)
---------------
Container     : shinsenter/php (built: 2024-09-27T16:30:39+0000)
Distro        : Debian GNU/Linux 12 (bookworm)
Timezone      : UTC (GMT+0000)
UID / GID     : www-data:www-data (33:33)
App Root      : /var/www/html
Document Root : /var/www/html
---------------
Docker Images by SHIN Company
Copyright (C) 2024 SHIN Company <[email protected]>
This software is free under the GNU General Public License (GPL).
You can redistribute and/or modify it under the terms of the GNU GPL.
This program is provided with the hope that it will be useful,
but it comes WITHOUT ANY WARRANTY. For more details, refer to the GNU GPL.
To get support, please contact: SHIN Company <[email protected]>
Docker Hub:      https://hub.docker.com/u/shinsenter
GitHub Packages: https://github.com/shinsenter?tab=packages
PHP 8.4.0RC1 (fpm-fcgi) (built: Sep 27 2024 05:50:54) (NTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.4.0RC1, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.0RC1, Copyright (c), by Zend Technologies
Deprecation Notice: Constant E_STRICT is deprecated in phar:///usr/local/bin/composer/src/Composer/Util/Silencer.php:36
Cron is running as www-data.
### Config:
CRON_TZ=UTC
HOME=/var/www/html
PATH=/var/www/html/vendor/bin:/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SHELL=/bin/sh
# Job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  *  command to be executed
# /etc/crontab.d/acellemail
* * * * * /usr/local/bin/php -q /var/www/html/artisan schedule:run | tee /tmp/cron-acellemail.txt
/etc/hooks/bootstrap/50-crontabs: line 58: kill: (282) - No such process
run-parts: /etc/hooks/bootstrap/50-crontabs exited with return code 1
Install PHP modules: imap

rollback on shinsenter/php:8.3-fpm => no problem

@quentingosset quentingosset reopened this Sep 30, 2024
@shinsenter
Copy link
Owner

Hi @quentingosset,

It seems that you are trying to install the IMAP module for PHP version 8.4, which is not yet supported. Could you try using version 8.3 instead?

You can check the supported modules for each PHP version here:
https://github.com/mlocati/docker-php-extension-installer/?tab=readme-ov-file#supported-php-extensions

@quentingosset
Copy link
Author

Hi @quentingosset,

It seems that you are trying to install the IMAP module for PHP version 8.4, which is not yet supported. Could you try using version 8.3 instead?

You can check the supported modules for each PHP version here: https://github.com/mlocati/docker-php-extension-installer/?tab=readme-ov-file#supported-php-extensions

Oh nice catch ! Actually, in 8.3 there are no problems at all

@quentingosset
Copy link
Author

quentingosset commented Nov 18, 2024

Hi @shinsenter, i re-open this ticket because crontask seems not work.
It seems that the crontask runs for the 1st minute of starting the docker container and then nothing. I just have 1 log of my crontask that is returned on startup and then I never have the crontask run again.
And I can't find any log on cron.

image
image
image

My observation is that if I restart the container from 0 (clean + re-pull), the cron works. If I simply restart the container, the cron no longer works.
and i got this :
image

@quentingosset quentingosset reopened this Nov 18, 2024
shinsenter added a commit that referenced this issue Nov 18, 2024
@shinsenter shinsenter reopened this Nov 18, 2024
@shinsenter
Copy link
Owner

@quentingosset

I believe I’ve identified the cause of the issue and have uploaded a patch. I’ll also rebuild all the Docker images, which will take a few hours to complete.

Please wait, pull the updated Docker image after a few hours, and test again to see if your issue is resolved.

@quentingosset
Copy link
Author

@quentingosset

I believe I’ve identified the cause of the issue and have uploaded a patch. I’ll also rebuild all the Docker images, which will take a few hours to complete.

Please wait, pull the updated Docker image after a few hours, and test again to see if your issue is resolved.

Thanks Shin.
Indeed, I found the correction strange in 71e6d40 because in the end the patch is simply the deletion in the stdin. Whereas the problem really seems to be in a specific case, which is rebooting the container.
Thanks, I'll wait for the patch and the container rebuild to keep you up to date :)

@quentingosset
Copy link
Author

@quentingosset

I believe I’ve identified the cause of the issue and have uploaded a patch. I’ll also rebuild all the Docker images, which will take a few hours to complete.

Please wait, pull the updated Docker image after a few hours, and test again to see if your issue is resolved.

Same problem with your last version. after a container reboot cron is not working

@shinsenter
Copy link
Owner

@quentingosset
I'm sorry to hear that the patch didn’t resolve your issue.
I’d like to investigate further and will provide another patch within the next few days, after the official release of PHP 8.4.

@shinsenter
Copy link
Owner

@quentingosset

The patched Docker images will also be updated shortly after the official Docker images for PHP 8.4 are released.

I hope the issue you're facing will soon be resolved when using the latest Docker images.

@quentingosset
Copy link
Author

@quentingosset

The patched Docker images will also be updated shortly after the official Docker images for PHP 8.4 are released.

I hope the issue you're facing will soon be resolved when using the latest Docker images.

After update the image with the latest one, all seems work perfectly with cron after a "restart container". I don't know if it a 8.4.1 php fix or if it's a fix from your side.

Just a strange thing i see, i pull your image from portainer and portainer return the image hash : sha256:d02d58c57d5f02428382a1e14650a5b60e4a4c4dfee02c930b04d9887128ef61
This hash seems not be your last dockerhub hash.
it's strange because all the image layers content is the same has your latest image : https://hub.docker.com/layers/shinsenter/php/8.4-fpm/images/sha256-81d131a606930f6137847134047d761e729041b232d1795009529a6e97eff87c?context=explore

@shinsenter
Copy link
Owner

I have no idea about portainer images

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants