How to replace certain backup files on a website every 30 minutes?
I have a website built with WordPress, unfortunately somebody hacked it several times, deleted my adsense code and put his own adsense.
I tried many security techniques, changed database name, did some stuff to prevent anybody from editing files through admin panel etc...
But this guy infiltrated and put his adsense code again yesterday. Because of this, I couldn't make any money yesterday, google adsense doesn't appear immediately, it takes more than 12 hours.
He only changes 2 files, header.php (template's file) and ads.txt (on the main directory).
How can I renew these 2 files (replace old ones with backup ones) every 30 minutes automatically?
Reverting the changes every 30 minutes is not a solution. You absolutely need to find out the root cause and stop this from happening by removing the vulnerability or the persistence. This may include monitoring the logs and other forensics, but also a fresh installation of WordPress (or in worst case the entire server) might be required.