Reloading cache

When running in the prod environment (which is always true unless you want to develop with Kimai) and you executed one of the following tasks within Kimai you need to reload its cache:

Kimai not only caches configuration files, but also the list of installed bundles and many other informations which are time consuming to calculate and which should not be evaluated on every request.

How to reload Kimai cache

bin/console kimai:reload --env=prod

FTP users: please have a look at this documentation.

If you are running an older version of Kimai (before 1.8) you have to use:

bin/console cache:clear --env=prod
bin/console cache:warmup --env=prod

It might be necessary to execute these commands as webserver user, read the Installation docs for more details.

Depending on your setup and the way you call the cache command, you have to fix directory permissions afterwards.

Fix Kimai file permission

You have to allow PHP (your webserver process) to write to var/ and it subdirectories.

Here is an example for Debian/Ubuntu (to be executed inside the Kimai directory):

chown -R :www-data .
chmod -R g+r .
chmod -R g+rw var/
chmod -R g+rw public/avatars/

Test Kimai before executing these commands (they are likely not required in a shared-hosting environment). You probably need to prefix them with sudo and the group might be called different than www-data.

Something went wrong / 500 error

This is very often caused by rebuilding the cache without fixing the file permissions.

Please check your logs at var/log/prod.log - if you can’t find that file it is even more likely that you have a permission problem!

Helper script

This little script can simplify the cache rebuilding task. Be careful if you don’t understand what it does!

  • Adjust the line chgrp -R www-data . and replace www-data with the username for your webserver
  • Create the file in the Kimai base directory
  • Allow to execute the file with chmod +x
  • Run the script ./

if [[ ! -d "var/" || ! -d "var/cache/prod/" ]];
 echo "Cache directory does not exist at: var/cache/prod/"
 exit 1

if [[ ! -f "bin/console" ]];
 echo "Kimai console does not exist at: bin/console"
 exit 1

rm -r var/cache/prod/*
bin/console kimai:reload --env=prod
chgrp -R www-data .
chmod -R g+r .
chmod -R 775 var/
chmod -R g+rw public/avatars/