On Fri, 2009-10-30 at 08:02 -0700, Suvayu Ali wrote:
Hi Dan,
On Friday 30 October 2009 03:11 AM, Dan Track wrote:
On Fri, Oct 30, 2009 at 9:56 AM, Cameron Simpsoncs@zip.com.au wrote:
On 30Oct2009 09:42, Dan Trackdan.track@gmail.com wrote: | Hi, | | I'm trying to run mutliple commands from the command line while using | nohup. But I can't seem to get the syntax right, can someone please | correct this for me | | nohup cmd 1;cm2;cmd3 | | All i get is that cmd1 runs from wiht nohup but the rest run in my | current shell. I'd like all to be run with the single nohup command, | any thoughts?
Syntacticly that's three command. A semicolon is like a newline, so its as though you've typed:
nohup cmd 1 cmd2 cmd3
Since nohup expects one command, you need one command. SInce you want three, invoke the shell as your command:
nohup sh -c 'cmd1; cmd2; cmd3'
Cheers,
Hi Cameron,
Many thanks for that gem.
I often find nohup very unreliable. I have had jobs fail submitted with nohup. I was thinking of switching to using screen. Maybe you could give that a try?
Screen is not an option if you want to set up a long-running job and log out. In what way has nohup failed on you? It's one of the oldest commands in the Shell toolbox and I've never had a problem with it.
Note that it's often a good idea to run it thus:
nohup command > OUTPUT 2>&1 &
poc