Using launchd to update MacPorts
You probably put the plist in ~/Library/LaunchAgents/. Since /opt/local is owned by root:wheel (that's at least the default), you don't have the proper permissions to write to certain necessary folders (e.g. /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/tmp). The log files (i.e. /var/log/org.macports.selfupdate.log/err) neither can be created, because only root can write to /var/log/.
So run the selfupdate service as launch daemon:
-
Remove the launch agent from the launchd database:
launchctl remove org.macports.selfupdate
-
Move the plist to /Library/LaunchDaemons/:
sudo mv ~/Library/LaunchAgents/org.macports.selfupdate.plist /Library/LaunchDaemons/org.macports.selfupdate.plist
-
Modify owner and permissions:
sudo chown root:wheel /Library/LaunchDaemons/org.macports.selfupdate.plist sudo chmod 644 /Library/LaunchDaemons/org.macports.selfupdate.plist
-
Load the daemon:
sudo launchctl load /Library/LaunchDaemons/org.macports.selfupdate.plist
Such launch daemon is run with root permissions and can update MacPorts data as well as write to /var/log/.