Thanks for the reply Rick but this hasn't helped. Firstly, most of my users are not allowed to login so I can't use "su".
You can try "su -c". I don't think that needs a shell, as it's the syntax used to start Linux system background processes. Run sa-learn as a direct child process of su.