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?
Thanks Dan
On 30Oct2009 09:42, Dan Track dan.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,
On Fri, Oct 30, 2009 at 9:56 AM, Cameron Simpson cs@zip.com.au wrote:
On 30Oct2009 09:42, Dan Track dan.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.
Cheers
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?
GL
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
On Fri, 2009-10-30 at 10:35 -0430, Patrick O'Callaghan wrote:
Screen is not an option if you want to set up a long-running job and log out.
Why not? That's the first thing I think of when I want to do just that.
'at' also works to start a job not connected to a terminal.
On Fri, 2009-10-30 at 14:19 -0400, Matthew Saltzman wrote:
On Fri, 2009-10-30 at 10:35 -0430, Patrick O'Callaghan wrote:
Screen is not an option if you want to set up a long-running job and log out.
Why not? That's the first thing I think of when I want to do just that.
You're right. I'd never played with screen and assumed it was just for multiplexing terminals.
poc
Matthew Saltzman wrote:
On Fri, 2009-10-30 at 10:35 -0430, Patrick O'Callaghan wrote:
Screen is not an option if you want to set up a long-running job and log out.
Why not? That's the first thing I think of when I want to do just that.
I concur. That is one of the main reasons "screen" was created in the first place.
There's also nohup. Just make sure you background the command as well:
nohup command &
---------------------------------------------------------------------- - Rick Stevens, Systems Engineer ricks@nerd.com - - AIM/Skype: therps2 ICQ: 22643734 Yahoo: origrps2 - - - - Time: Nature's way of keeping everything from happening at once. - ----------------------------------------------------------------------
On Fri, Oct 30, 2009 at 3:32 PM, Rick Stevens ricks@nerd.com wrote:
Matthew Saltzman wrote:
On Fri, 2009-10-30 at 10:35 -0430, Patrick O'Callaghan wrote:
Screen is not an option if you want to set up a long-running job and log out.
Why not? That's the first thing I think of when I want to do just that.
I concur. That is one of the main reasons "screen" was created in the first place.
There's also nohup. Just make sure you background the command as well:
nohup command &
And there is disown for those times when we forget all of the above.
John
Hi Patrick,
Patrick O'Callaghan wrote:
On Fri, 2009-10-30 at 08:02 -0700, Suvayu Ali wrote:
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 &
Whenever I have used nohup I have used it exactly the way you have mentioned. And many times I later found out my job had failed when I had logged out. Since then I have stopped using nohup and wanted to look into screen. Until I do that I just don't log out any more unless I am sure my job has finished. Maybe the unreliability I have experienced is due to the versions of nohup I use (what ever comes as default with Scientific Linux 4, thats way too old).
`screen' on the other hand runs all your jobs independent of your login shell, as a post later in the thread has pointed out. It runs on the remote machine, and manages the jobs you want to execute. So unless screen itself crashes its pretty much safe to say the job will complete successfully.
Hopefully this clears up any doubts for you. I should definitely find some time to get familiar with screen. :-\
poc
Cheers,
On Fri, Oct 30, 2009 at 03:38:34PM -0700, Suvayu Ali wrote:
Hi Patrick,
Patrick O'Callaghan wrote:
On Fri, 2009-10-30 at 08:02 -0700, Suvayu Ali wrote:
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 &
Whenever I have used nohup I have used it exactly the way you have mentioned. And many times I later found out my job had failed when I had logged out. Since then I have stopped using nohup and wanted to look into screen. Until I do that I just don't log out any more unless I am sure my job has finished. Maybe the unreliability I have experienced is due to the versions of nohup I use (what ever comes as default with Scientific Linux 4, thats way too old).
`screen' on the other hand runs all your jobs independent of your login shell, as a post later in the thread has pointed out. It runs on the remote machine, and manages the jobs you want to execute. So unless screen itself crashes its pretty much safe to say the job will complete successfully.
Hopefully this clears up any doubts for you. I should definitely find some time to get familiar with screen. :-\
poc
Many years ago (15 or more, likely more) I found a little program on (I think it was) comp.sources.unix or similar, named "detach". I still use it because it really, certainly detaches your program from your terminal. The docs say something like "once you've detached your program you can box up your terminal and mail it to Brazil and the program won't know or care." and it's true. as long as the machine continues to run, you can log out and in and out and in and do whatever else you wish and it won't disturb the program.
I can probably dig up the sources and email them to any of you who may wish to have it. I have no place to post it for downloading. and having just gone looking for it, I still have detach.c and Makefile but seem to have lost the documentation (which isn't critical).
Fred
On Fri, 2009-10-30 at 15:38 -0700, Suvayu Ali wrote:
Hi Patrick,
Patrick O'Callaghan wrote:
On Fri, 2009-10-30 at 08:02 -0700, Suvayu Ali wrote:
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 &
Whenever I have used nohup I have used it exactly the way you have mentioned. And many times I later found out my job had failed when I had logged out. Since then I have stopped using nohup and wanted to look into screen. Until I do that I just don't log out any more unless I am sure my job has finished. Maybe the unreliability I have experienced is due to the versions of nohup I use (what ever comes as default with Scientific Linux 4, thats way too old).
I guess commands under nohup can fail if they expect to send output to a physical terminal, which presumably screen handles better. I can't think what other reason could make them fail. Anything written to be used as a filter shouldn't have this problem, but of course it depends what you're doing.
poc