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

Different path to PHP not respected in crontab > scheduled tasks. #2196

Closed
bazizsafi opened this issue Sep 5, 2022 · 5 comments
Closed

Different path to PHP not respected in crontab > scheduled tasks. #2196

bazizsafi opened this issue Sep 5, 2022 · 5 comments

Comments

@bazizsafi
Copy link

Hi,

on our web hoster we need to use a different path to PHP to select the correct PHP version. Instead of /usr/bin/php we need to use /usr/bin/php8.0.
No big deal, this is covered in the installation guide at https://github.com/freescout-helpdesk/freescout/wiki/Installation-Guide#9-configuring-cron-jobs.

However, setting this path to PHP in the crontab does not change the path to PHP of the scheduled tasks:

This is the crontab with the desired path to PHP:

* * * * * /usr/bin/php8.0 /path/to/freescout/installation/artisan schedule:run >> /dev/null 2>&1

When I run this command manually, it reveals that the scheduled tasks use the default path to PHP '/usr/bin/php':

$ /usr/bin/php8.0 /path/to/freescout/installation/artisan schedule:run
Running scheduled command: '/usr/bin/php' 'artisan' freescout:fetch-monitor > '/dev/null' 2>&1
Running scheduled command: '/usr/bin/php' 'artisan' freescout:check-conv-viewers > '/dev/null' 2>&1
Running scheduled command: '/usr/bin/php' 'artisan' freescout:fetch-emails > '/path/to/freescout/installation/storage/logs/fetch-emails.log' 2>&1
Running scheduled command: '/usr/bin/php' 'artisan' queue:work --queue='emails,default,1e0dfc970c9f3c1aca93f5554779bc52' --sleep=5 --tries=1 > '/path/to/freescout/installation/storage/logs/queue-jobs.log' 2>&1
Content-type: text/html; charset=UTF-8

$

How do I make the scheduled tasks also use our desired path to PHP?

@freescout-helpdesk
Copy link
Contributor

Good question. We don't know yet.

@freescout-helpdesk
Copy link
Contributor

It looks like there is no some good way. The only way is to hardcode the path to your PHP like this: https://stackoverflow.com/a/45962045

@bazizsafi
Copy link
Author

bazizsafi commented Sep 12, 2022

Closed as completed, hm? You guys are quick! ;-)

Well, I concur this is not really a FreeScout issue, but rather a Symfony issue. This Stackoverflow question lead me onto the right path. Obviously PhpExecutableFinder has trouble identifying the current PHP process in PhpExecutableFinder.php:57 when called from a crontab environment.

However, defining PHP_PATH to the desired path to PHP would make PhpExecutableFinder return it (as long as it is an executable file).

Unfortunately, defining PHP_PATH in FreeScout's .env file does not solve the issue. It doesn't seem to be regarded in the crontab environment.

So I crudely fixed the problem by defining PHP_PATH right in the crontab environment with the following crontab command:

* * * * * export PHP_PATH=/usr/bin/php8.0; $PHP_PATH /path/to/freescout/installation/artisan schedule:run >> /dev/null 2>&1

You might want to include this approach (or something more elegant) in your documentation to help all those FreeScout users on shared/hosted webspace.

@freescout-helpdesk
Copy link
Contributor

Thanks for sharing the solution. Added to https://github.com/freescout-helpdesk/freescout/wiki/Installation-Guide

@bazizsafi
Copy link
Author

You're welcome, I have to thank you for this awesome software!!

One tiny remark regarding the Installation Guide:
In the example, you're using /usr/local/bin/php-8.0 on the one hand and /usr/bin/php8.0 on the other hand.
I mean, you could use different paths at those different places and people will still figure it out, I guess, but it's inconsistent and might confuse less technically-skilled users.

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