---
# System prepended metadata

title: Cleanup (?) Service

---

# Cleanup (?) Service

##  DB.Collection crons
> name - friendly name
> value - the value depends on the option we choose
```
{
    cronId: number,
    name: string,
    value: any,
}
```

Example:
```
[
    {
        cronId: 1,
        name: 'Every hour',
    },
    {
        cronId: 2,
        name: 'Every Day',
    },
]
```
##  DB.Collection cronJobs

> systemEventId - This system event what we need create when this cron executed
```
{
    cronJobId: number,
    cronId: number,
    systemEventId: string,
}
```

Example:
```
[
    {
        cronJobId: 1,
        cronId: 1,
        systemEventId: 56,
    },
    {
        cronJobId: 1,
        cronId: 2,
        systemEventId: 57,
    },
]
```
##  DB.Collection actions

We need add new field for creating system actions(clean rake user app profiles ...). That means that this actions can be setuped only via admin UI. You can\`t use this jobs insde parameters.json.

```
{ 
    actionId: number,
    name:string,
    isSystem: boolean
}
```

Main flow:
> Skip part with cron jobs
1.We have package in cronEvents topic. This event will be resend to all subscription queue what it has.
2.Event trigger logic service will catch this pack and send request for creating system event.
3.Core service will be create system event and push package to system events queue
4.Event trigger service catch pack with system event and execute all triggers for it

## Version 1

Description:
We can use a micro f1 VM with Linux. There we can create a crontab file with all cron jobs that we need. And create simple API for CRUD operation. 
![](https://i.imgur.com/xhXG9HJ.png)

## Version 2

Other service for creating and manage cron jobs
[posible services](https://www.cronjobservices.com)
![](https://i.imgur.com/JmmEnBs.png)
