Within our application we make use of a environment variable named SERVER_ENV that is used to set whether we are in a production or development environment. This is set through the httpd.conf file for apache. The issue we are having is that using the scheduled task command below set through the Plesk administration interface there is of course no interaction with apache and so the environment variable is not set.

The command used is as follows:

/usr/bin/php -d safe_mode=Off  /var/www/vhosts/example.com/httpdocs/index.php cron file-cleanup

Having spent some time researching it would appear that I could set the variable using:


but I've tried various methods and this does not appear to be picked up.

Can anybody shed any light as to where I can include this within the command string?

1 Answer 1


You could try something like

export SERVER_ENV="production"; /usr/bin/php -d ...

which sets the environment variable SERVER_ENV to production which can then bve read by php $server_environment=getenv("SERVER_ENV");

  • that seems to work thanks. Excuse my stupidity though, could you offer a quick explanation as to what "export" is actually doing here? Dec 20, 2011 at 10:09
  • 1
    the export causes the environment variable SERVER_ENV to be passed into the environment of child processes. Without the export your php wouldn't see it.
    – user9517
    Dec 20, 2011 at 10:25

You must log in to answer this question.

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