As many people, I have some custom update script which...

One thing it also does is updating all emacs packages I have installed and how that works is the topic of this posting.

On the emacs side, you have to install the auto-package-update. I do that using use-package in my ~/.emacs like so:

(use-package auto-package-update
  :ensure t
  ;; Yes, please delete the old version on updates.
  (setq auto-package-update-delete-old-versions t))

The package provides a function auto-package-update-now which I simply call from my shell script.

$ emacs --eval '(progn (sit-for 2) (auto-package-update-now))'

Don't ask me why I use --eval including the sit-for. I guess there were reasons but I simply cannot remember...

Well, you can also just use this simpler recipe.

$ emacs -f auto-package-update-now

That seems to work just as well. Try it out! If there's some case where that fails but the --eval '(progn (sit-for 2) (auto-package-update-now))' version works, please drop me a mail and remember me of the reasons I've had back then.