I'm assuming you are running recent version of ubuntu or a distribution based on upstart. You can check /var/log/daemon.log
for errors.
The standard su
takes the syntax su [options] [username]
. Checkout man 1 su
. You might want to try :
su -c "myCommand" anotheruser >> "myLogfile.log"
Also, a couple of things would happen (mostly not desirable)
myLogfile.log
would be owned by root
.
myLogfile.log
would be created on /
(root directory) if you don't use an absolute path like /tmp/myLogfile.log
(because upstart runs with pwd set to /
).
If you want the file to be owned by anotheruser
you might switch the command to.
su -c "myCommand >> /tmp/myLogfile.log" anotheruser
This might cause problems if you have leftover myLogfile.log
owned by root
from earlier runs or if have not changed myLogfile.log
to something like /tmp/myLogfile.log
(normally, regular users can't create files on root dir /
).
cron
, i.e. acrontab
@reboot
entry, I suppose. (Output will be sent via mail.) – sr_ Feb 24 '12 at 10:05