You can call :timer.send_interval(30_000, :delete_posts) in the init/1 callback.
And then
def handle_info(:delete_posts, state) do
delete_expired_posts()
{:noreply, state}
end
Edit: Now if you do not know anything about GenServer I must warn you that there are several concepts to understand (although in the end it is quite simple). A CRON will work well, and you can also look at Quantum though it is overkill if you only need one kind of periodic job.






















