0

I run a .sh bash file from a directory httpdocs/pub/ftp-admin/. On the command line from the directory everything works fine. If i make a cron task in plesk all magento 2 commands are not working and ik get this message.

Magento supports PHP 7.1.3 or later.

see script below. what is wrong. I run: CentOS Linux 7.8.2003 with php 7.2.31

#!/usr/bin/env bash

file=*.ZIP
  if [ -f $file ]
    then
      echo $file "exist"
    # 
        cp $file ./backup
    # 
    unzip -P web $file
    # 
    rm -f $file
   fi
    # 
   if [ -f *BASIC.XML ]
    then
    mv *_BASIC.XML BASIC.XML
    php -f ../../bin/magento import:job:run 1
   fi
    # 
   if [ -f *PRICES.XML ]
        then
        mv *_PRICES.XML PRICES.XML
        php -f ../../bin/magento import:job:run 4
    php -f ../../bin/magento import:job:run 2 
   fi
    # 
   if [ -f *STOCKINFO.XML ]
        then
        mv *_STOCKINFO.XML STOCKINFO.XML
        php -f ../../bin/magento import:job:run 3
   fi
    # 
    cp -f *.XML ./backup
    # 
    rm -f *.XML
2
  • Your scripts seems truncated at the end. You also don't mention in what way the script doesn't work when you run it from cron. You seem to be expecting that your globbing patterns to expand to single filenames, always. Will there ever be more than one .ZIP file in the directory when you run the -f *.ZIP test (and likewise for the other tests)?
    – Kusalananda
    Commented Jun 9, 2020 at 13:56
  • It’s not about the script it’s that php from from is not running the magento script. This is solved as mention below
    – marcel
    Commented Jun 10, 2020 at 15:01

2 Answers 2

1

You need to set the PATH variable for the commands ( /path/to/the/bin/magento here ) accordingly whenever you are using script in crontab.

Ex: PATH=$PATH:/path/to/the/bin/magento

To use ../ and ./ in the script either cd to the directory in the script where you are executing the script or always use Full-path like /path/to/the/bin/magento

3
  • same result: Magento supports PHP 7.1.3 or later.
    – marcel
    Commented Jun 8, 2020 at 15:56
  • @marcel : Is there several php version installed in your system ? if so , which one's binary is in the PATH list ? Commented Jun 8, 2020 at 16:00
  • see this list; on 7.1.33 FastCGI application 0 on 7.1.33 FPM application 0 off 7.2.31 CGI application on 7.2.31 FastCGI application 0 on 7.2.31 FPM application 2 off 7.3.18 CGI application on 7.3.18 FastCGI application 0 on 7.3.18 FPM application
    – marcel
    Commented Jun 8, 2020 at 19:03
0

Problem is solved. Cron tasks in plesk are running under a lower PHP version then from SSH. By editing the script like this the problem was solved:

/opt/plesk/php/7.2/bin/php -f $MAGEPATH/magento import:job:run 1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .