# Bug OP-11141 - Deleting tmp/cache works when called manually but never by scheduled jobs

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-11141

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | High |
| Module |  |
| Target versions | 12.4.4 |
| Observed in versions | 11.4.0 |
| Sprint | 12.4.4 |
| Backlog bucket |  |
| Bug found in version (deprecated) | 11.4.x |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

### Steps to reproduce

  - We have no idea.

### What is the buggy behavior?

  - The rake job does not clean the tmp/cache dir

### What is the expected behavior?

  - The rake job cleans the tmp/cache dir

### Findings so far:

  - job is scheduled periodically
  - manual execution works as expected
  - scheduled execution happens but does not work

### Logs

``` bash
root@opsrv:~# du -sh /opt/openproject/tmp/cache/
1.4G    /opt/openproject/tmp/cache/

root@opsrv:~# openproject run bundle exec rails runner 'Cron::ClearTmpCacheJob.perform_now'
/opt/openproject/config/constants/settings/definition.rb:307:in `find_env_var_override': Using unprefixed environment variables is deprecated. Please use OPENPROJECT_ATTACHMENTS_STORAGE_PATH instead of ATTACHMENTS_STORAGE_PATH (StructuredWarnings::StandardWarning)
/opt/openproject/config/constants/settings/definition.rb:307:in `find_env_var_override': Using unprefixed environment variables is deprecated. Please use OPENPROJECT_RAILS_CACHE_STORE instead of RAILS_CACHE_STORE (StructuredWarnings::StandardWarning)
/opt/openproject/config/constants/settings/definition.rb:307:in `find_env_var_override': Using unprefixed environment variables is deprecated. Please use OPENPROJECT_RAILS_RELATIVE_URL_ROOT instead of RAILS_RELATIVE_URL_ROOT (StructuredWarnings::StandardWarning)
W, [2022-08-24T12:06:45.363566 #460794]  WARN -- : Creating scope :open. Overwriting existing method GithubPullRequest.open.
I, [2022-08-24T12:06:49.229426 #460794]  INFO -- : [ActiveJob] [Cron::ClearTmpCacheJob] [339989cf-fadc-44de-92dc-91d4d8687694] Performing Cron::ClearTmpCacheJob (Job ID: 339989cf-fadc-44de-92dc-91d4d8687694) from DelayedJob(default) enqueued at
I, [2022-08-24T12:06:49.232689 #460794]  INFO -- : [ActiveJob] [Cron::ClearTmpCacheJob] [339989cf-fadc-44de-92dc-91d4d8687694] Invoking Rake task tmp:cache:clear.
I, [2022-08-24T12:07:04.962806 #460794]  INFO -- : [ActiveJob] [Cron::ClearTmpCacheJob] [339989cf-fadc-44de-92dc-91d4d8687694] Performed Cron::ClearTmpCacheJob (Job ID: 339989cf-fadc-44de-92dc-91d4d8687694) from DelayedJob(default) in 15733.15ms

root@opsrv:~# du -sh /opt/openproject/tmp/cache/
13M     /opt/openproject/tmp/cache/
```

``` shell
root@opsrv:~# journalctl -u openproject-worker-1 | grep ClearTmpCacheJob
Aug 28 04:45:01 opsrv openproject-worker-1.service[34145]: I, [2022-08-28T04:45:01.229270 #34145]  INFO -- : [ActiveJob] [Cron::ClearTmpCacheJob] [46e7b532-5662-483f-8c65-8232c851ca6a] Performing Cron::ClearTmpCacheJob (Job ID: 46e7b532-5662-483f-8c65-8232c851ca6a) from DelayedJob(default) enqueued at 2021-05-10T14:44:36Z
Aug 28 04:45:01 opsrv openproject-worker-1.service[34145]: I, [2022-08-28T04:45:01.230817 #34145]  INFO -- : [ActiveJob] [Cron::ClearTmpCacheJob] [46e7b532-5662-483f-8c65-8232c851ca6a] Invoking Rake task tmp:cache:clear.
Aug 28 04:45:01 opsrv openproject-worker-1.service[34145]: I, [2022-08-28T04:45:01.231077 #34145]  INFO -- : [ActiveJob] [Cron::ClearTmpCacheJob] [46e7b532-5662-483f-8c65-8232c851ca6a] Performed Cron::ClearTmpCacheJob (Job ID: 46e7b532-5662-483f-8c65-8232c851ca6a) from DelayedJob(default) in 1.74ms
Sep 04 06:00:00 opsrv openproject-worker-1.service[34145]: I, [2022-09-04T04:45:01.166295 #34145]  INFO -- : [ActiveJob] [Cron::ClearTmpCacheJob] [46e7b532-5662-483f-8c65-8232c851ca6a] Performing Cron::ClearTmpCacheJob (Job ID: 46e7b532-5662-483f-8c65-8232c851ca6a) from DelayedJob(default) enqueued at 2021-05-10T14:44:36Z
Sep 04 06:00:00 opsrv openproject-worker-1.service[34145]: I, [2022-09-04T04:45:01.167948 #34145]  INFO -- : [ActiveJob] [Cron::ClearTmpCacheJob] [46e7b532-5662-483f-8c65-8232c851ca6a] Invoking Rake task tmp:cache:clear.
Sep 04 06:00:00 opsrv openproject-worker-1.service[34145]: I, [2022-09-04T04:45:01.168329 #34145]  INFO -- : [ActiveJob] [Cron::ClearTmpCacheJob] [46e7b532-5662-483f-8c65-8232c851ca6a] Performed Cron::ClearTmpCacheJob (Job ID: 46e7b532-5662-483f-8c65-8232c851ca6a) from DelayedJob(default) in 1.92ms
Sep 11 06:00:00 opsrv openproject-worker-1.service[34145]: I, [2022-09-11T04:45:00.837694 #34145]  INFO -- : [ActiveJob] [Cron::ClearTmpCacheJob] [46e7b532-5662-483f-8c65-8232c851ca6a] Performing Cron::ClearTmpCacheJob (Job ID: 46e7b532-5662-483f-8c65-8232c851ca6a) from DelayedJob(default) enqueued at 2021-05-10T14:44:36Z
Sep 11 06:00:00 opsrv openproject-worker-1.service[34145]: I, [2022-09-11T04:45:00.839288 #34145]  INFO -- : [ActiveJob] [Cron::ClearTmpCacheJob] [46e7b532-5662-483f-8c65-8232c851ca6a] Invoking Rake task tmp:cache:clear.
Sep 11 06:00:00 opsrv openproject-worker-1.service[34145]: I, [2022-09-11T04:45:00.839549 #34145]  INFO -- : [ActiveJob] [Cron::ClearTmpCacheJob] [46e7b532-5662-483f-8c65-8232c851ca6a] Performed Cron::ClearTmpCacheJob (Job ID: 46e7b532-5662-483f-8c65-8232c851ca6a) from DelayedJob(default) in 1.77ms
```
