Is logrotate supposed to work only in logs inside /var/log?

If it performs the rotation with --force, then that implies that your configuration is fine, but logrotate does not believe that the file needs to be rotated at this time.

You can run logrotate -v /etc/logrotate.d/[your conf file] and it should provide a message stating why it is skipping the file. If not, logrotate -d will give additional debugging information that's likely to help pinpoint the cause.

However, looking at your posted configuration, I'm going to guess that the most likely reason is that nothing has actually been written to /opt/my_tests/my.log (i.e., the file has a size of 0), and your config states notifempty, so the file will be skipped if it has size 0.


  • logrotate works on any directory you configure, not only /var/logs
  • your configuration is missing the period when rotation should happen (daily, weekly, ...)
  • on Ubuntu, logrotate job is triggered by cron. So have a look at /etc/cron.d/ when exactly it would run
  • depending on your configuration, it could take some days until logrotate actually rotates the file