Sean Doe
Sean Doe

Reputation: 1

Imagick not found when ran in the background

I'm trying to run Imagick in the background but I am getting the error PHP Fatal error: Uncaught Error: Class "Imagick" not found in PATH_TO_BACKGROUND_FILE.php

By "running in the background", I mean a background process that runs on its own and doesn't make the rest of your php script have to wait on it to continue. Example/tutorial here: https://www.geeksforgeeks.org/how-to-execute-a-background-process-in-php/

It runs fine when not in the background but not when ran in the background using this command /usr/local/bin/php ' . escapeshellarg($file_path) . ' ' . escapeshellarg($var1) . ' ' ... ' ' . escapeshellarg($var8) . ' > /dev/null 2>&1 &

These are the lines of code I'm using to make a file run in the background:

putenv("PATH=/usr/local/bin:/usr/bin:/bin");
$command($the_command_above_starting_with_usr/local/bin/php);
exec($command);

I tried searching "imagick not found in background script" but I don't think any of the questions/answers are talking about running it in the background and only talking about Imagick not being found because it isn't installed properly, not installed at all and other stuff that doesn't tackle the difference that running in the background may cause.

In regards to my question being regarded as a duplicate, I am not running this in Laravel and I am trying to figure out and solve why Imagick is working in a regular non-background script but not when ran as a background process. I ran php -i on both the script that's ran normally (not in the background) and in the file that's ran in the background. I found "imagick" installed in the normal script but not in the background script.

Upvotes: -1

Views: 24

Answers (0)

Related Questions