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
  • 13,050
  • 4
  • 41
  • 79
IAmJulianAcosta
  • 1,082
  • 2
  • 14
  • 30

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
  • 88,541
  • 4
  • 65
  • 105