How to check there is existing task and just overwrite it instead of add new one

assume i have an important task that needs to always run every day or every week. maybe there is a bug or i just need to checnge the logic. what are the best practices?

as i searched i need to use filters but dont know how it works. can you show me a good code sample?