3

I'm using a cron job that runs a PHP script like this:

* * * * * php /path/to/script schedule:run >> /dev/null 2>&1

But is running with older version of PHP. When I run which PHP I get /path/to/php7.0, and I need to change the path used by cron to run PHP. Is this possible without specifying it in cron job like this?

* * * * * /path/to/php7.0 /path/to/script schedule:run >> /dev/null 2>&1
Darren
  • 12,924
  • 4
  • 37
  • 76
IAmJulianAcosta
  • 932
  • 2
  • 12
  • 28

2 Answers2

0

You can used symbolic link.

Remove the current php executable file

Then.

ln -s /path/to/php7.0 php (location of php executable file)
Edmar
  • 21
  • 5
0

Add your "new" php path to the system $PATH variable by editing .bash_profile or .bashrc file:

export PATH=/path/to/php7.0:$PATH

(replace /path/to/php7.0 with your actual php path)

RomanPerekhrest
  • 75,918
  • 4
  • 51
  • 91