0

I have a java program on autostart in rc.local (in ubuntu its /etc/init.d/rc.local) For some reason in ubuntu on autostart the command to execute java and log its output only half works, while it works as expected in the command line and it also works on any RHEL distro (in rc.local and command line). the command im trying to execute is:

java -server -cp '/foo/bar/' SomeServer &> '/foo/bar/log.txt' &

At boot in ubuntu it just starts the server and rewrites log.txt to a blank log, but doesnt log any more of the output of the server program... All the permissions are definitely set right.. not sure what else to look into.. Any help is appreciated. Thanks.

Sigtran
  • 329
  • 1
  • 6
  • 15
  • 1
    Are you sure about the `&>`? I always do `command > some/logfile.txt 2>&1 &`. – tauran Feb 09 '11 at 10:57
  • &> should log errors as well (or thats what it does in RHEL).. will try the other way now, thanks (and as ive said, it works if i try it from the command line ;/) – Sigtran Feb 09 '11 at 10:59
  • oh, wow, actually this did the trick.. not sure why it wouldnt work in ubuntu tho.. im using the same shell in all distros. Thank you – Sigtran Feb 09 '11 at 11:06

1 Answers1

1

So here's my answer then :)

Do:

command > some/logfile.txt 2>&1 &

rc.local is executed by /bin/sh not /bin/bash and this makes the difference.

tauran
  • 7,986
  • 6
  • 41
  • 48