Cronjobs

Cronjobs

Cronjobs are a way to schedule tasks to run at specific times. They are used to automate system maintenance or administration tasks, such as backing up databases, cleaning up log files, etc.

I mainly use cronjobs on my GitLab-Runners to clean up every 12 hours. I did not configure my GitLab-Runners to clean up after themselves, so I have to do it manually.

Crontab

On every ubuntu (linux) server you can use the crontab command to create, view, and edit your cronjobs.

crontab -e

This will open the crontab file in your default editor. Here you can add your cronjobs.

In my case I have the following cronjob to clean up my GitLab-Runners every 12 hours.

0 */12 * * * /usr/bin/docker system prune -a -f
 
0 */12 * * * /usr/bin/docker volume prune -f