Doing that is risky. You could get a bad package that crashes your system.
If you really insist there's already an APT auto-updater package in DebIan / Raspbian.
I'm on a phone now so it's not easy for me to find that.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+
Any DMs sent on Twitter will be answered next month.