gjcarneiro / yacron

A modern Cron replacement that is Docker-friendly
MIT License
449 stars 38 forks source link

Scheduled command failing when running with yacron #84

Open FluffyDiscord opened 1 year ago

FluffyDiscord commented 1 year ago

Description & What I Did

I am trying to run PHP command (Symfony framework) via yacron every minute. For some reason, the command fails when it's run with yacron, but works just fine when running manually within the docker container. All the packages are present and work just fine, but once it's running with yacron, I get the following error

PHP Warning:  PHP Startup: Unable to load dynamic library 'imagick' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20210902/imagick (/usr/local/lib/php/extensions/no-debug-non-zts-20210902/imagick: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20210902/imagick.so (/tmp/_MEI4v2QWZ/libz.so.1: version `ZLIB_1.2.9' not found (required by /usr/lib/x86_64-linux-gnu/libpng16.so.16))) in Unknown on line 0

Is yacron loading system libraries/env in a different way or something like that?

Yacron is running as root just as the manual command is also ran as root user. There is no user mismatch. Yacron has execution permissions chmod +x yacron

gjcarneiro commented 1 year ago

I don't think yacron is doing anything special. Most likely some difference between environment variables. I suggest you create a cron job that runs the command env, which will print the environment variables. Then run the same env outside yacron. Sort both and diff them to try to find what is different, e.g.:

yacron cron job: env | sort > /tmp/env-yacron.txt
command outside: env | sort > /tmp/env-outside.txt && diff -u /tmp/env-outside.txt /tmp/env-yacron.txt