Run script as root whenever any user logs in What's the best way to run a script with root privileges whenever any user logs in? It should run in the background without prompting the user for a password.
Use a LoginHook.

sudo defaults write com.apple.loginwindow LoginHook /path/to/script


See here for more detail.