Cleaning script on shutdown

I’m thinking of creating a script that will solve some problems. For example I have concerns about .xsession-errors & .xsession-errors.old which will delete them safely and without creating a new problem. I think it would be a good database to solve some issues that reappear on restart.Example someone more experienced could add something to the hypothetical list and be included in the script list. how do you like the idea?