1

I have a symfony app, which I pushed to production server according to the Smyfony Help Page here.

I have a command cronjob, that parses the logfiles by the enviroment, like this:

$env = $this->getContainer()->getParameter("kernel.environment");

    /* Read Logfile */
    $fs = new Filesystem();
    if ($fs->exists(Constants::LOG_PATH . '/'.$env.'_error-' . $yesterday->format('Y-m-d') . '.log')) {
     ...
   }else{
     /*Send mail for fail */
   }

When I do export SYMFONY_ENV=prod and run the command manually, it works. At night it fails because the dev log does not exist. I also added the export SYMFONY_ENV=prod to ~/.bashrc according to this, still no luck.

Where am I wrong?

Community
  • 1
  • 1
PrimuS
  • 2,505
  • 6
  • 33
  • 66
  • You might find your answer here: http://stackoverflow.com/questions/2229825/where-can-i-set-environment-variables-that-crontab-will-use – Bartosz Zasada Jul 11 '16 at 07:49

1 Answers1

0

You can add the env to your cron like:

*/30 * * * * SYMFONY_ENV=prod php /usr/share/nginx/html/test/bin/console cache:clear
Crofly
  • 396
  • 3
  • 4