Foreman Tasks Cleanup

Is there a suggested way to automate the tasks cleanup?

I had thought maybe by using the cleanup section it would automatically run task cleanup, but it seems I have to run it manually each time. I know I can simply setup a cronjob, but is there a different method that is more recommended?

I think this is documented as cronjob: Configuring the cleaning unused tasks feature in Administering Foreman+Katello. Does that help?

1 Like

Currently cron is the recommended way. I think this will be replaced by systemd timer in the future likely when moving to EL10.

1 Like

Thank you both! cron it is.

On our foreman/katello server there is a file /etc/cron.d/foreman-tasks which has been generated by foreman-installer. It runs the clean up every day:

SHELL=/bin/sh
RAILS_ENV=production
FOREMAN_HOME=/usr/share/foreman
TASK_BACKUP=false

# Clean up expired tasks from the database

45 19 * * *    foreman    /usr/sbin/foreman-rake foreman_tasks:cleanup >>/var/log/foreman/cron.log 2>&1

Thus if it is not working for you I’d rather wonder why it’s missing. You should check the current state of the foreman-plugin-tasks-automatic-cleanup installer option.

You don’t have to set up a cron job yourself.

1 Like