WebFaction
Community site: login faq

Hi there,

When I run php -v from the command line, I get version 5.6.17. Great!

However, if I enter php -v into a shell script, and schedule it to run with Cron, the output shows PHP version 5.4.16. This is a problem, as I'm using CakePHP Console commands, and version 5.4.16 is configured differently. I would like the cron PHP to use 5.6 as per CLI.

Running 'which php' from a script scheduled with Cron outputs '/usr/bin/php'. I need this to be using /usr/local/bin/php.

I can edit the CakePHP cake script to use /usr/local/bin/php, but don't want to edit core CakePHP files...

Is there another solution?

Many thanks.

asked 06 Feb '16, 23:44

s512
2612
accept rate: 100%

Hello,

You can invoke a certain version of PHP for your cron like this:

/usr/local/bin/php56

Among other versions available: php54 php55 php70

I hope this helps. If there are further issues. Feel free to open a support ticket.

(07 Feb '16, 05:20) NickR ♦♦

Problem with this is that I would have to edit the CakePHP shell script, which I don't really want to do. The shell script is just using 'php' - is there any way of forcing 'php' to invoke a certain version?

If I run 'php' from the CLI, it runs the correct version. Only from cron it doesn't. Thanks.

(07 Feb '16, 15:07) s512

In fact, I'll just create a new script and run that when on WebFaction. That'll do it.

Still, be interested to know if there's a way of changing the php used by Cron (using command 'php') :)

permanent link

answered 07 Feb '16, 15:19

s512
2612
accept rate: 100%

You would need to edit the CakePHP shell script or create a script called via cron that sets a php alias for php 5.6 and then launches your CakePHP shell script.

permanent link

answered 07 Feb '16, 15:18

aaront ♦♦
7664
accept rate: 27%

@aaront, we replied at the same time. That would work also, thanks. For now I have created a new script that uses the right version, and am calling that from cron.

(07 Feb '16, 22:21) s512

On behalf of Aaron, you are most welcome. Let us know if there is anything else.

(07 Feb '16, 22:29) NickR ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×262
×81
×7

question asked: 06 Feb '16, 23:44

question was seen: 3,043 times

last updated: 08 Feb '16, 23:43

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM