I just got tired of typing each command in manually every time, so I just put them in a shell script:
#!/bin/bash if [ "$(whoami)" != 'root' ]; then echo "You have no permission to run $0 as non-root user." exit 1 fi export PATH=/opt/local/bin:/opt/local/sbin:$PATH port selfupdate port -d sync port upgrade outdated port clean --all installed >> /dev/null 2>&1 port uninstall inactive
The last two are just because I don’t like “extra junk” building up on my systems & by default MacPorts doesn’t remove previous versions or clean up after itself.
You can save the script, make it executable, & put it somewhere in your path so when you’re ready to update MacPorts, you can just type “sudo
I also considered scheduling this, but in my experience it doesn’t always finish successfully (usually due to a bad download of the sourcecode), so the process needs to be monitored while it’s happening. Otherwise, you could eventually wind up with a broken ports collection.