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
Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3
Please post ALL technical questions on the forum. Do not send private messages.