You are not logged in.
Pages: 1
Long story short: I use SSH to connect to my work computer, but the connection gets dropped after a certain number of hours (It's supposed to, I just don't know why). I have some jobs that I send that take longer than the allowed time, so the solution is to use nohup:
nohup command
So that when my ssh dies, the job is still running.
But I want to have this computer chugging along all weekend with several commands. Would I do this?
nohup command1 && nohup command2 && nohup command3
Also, what if I write a very short script with all these commands in it and then just ran:
nohup script
That would be nice, but I don't know how to write a bash script at all. Do I just make a list of commands and save it as script.sh?
Offline
did you try screen?
Offline
Don't I have to have screen installed on the work computer to do what I'm doing? I don't have root privileges, so I can't install stuff.
Offline
nohup command1 && nohup command2 && nohup command3
Untested, but I think that would fail... I would try
nohup $(command1 && command2 && command3)
Also, what if I write a very short script with all these commands in it and then just ran:
nohup script
That would be nice, but I don't know how to write a bash script at all. Do I just make a list of commands and save it as script.sh?
A bash scrpit is easy...
#!/bin/bash
command1
command2
command3
Offline
Untested, but I think that would fail... I would try
nohup $(command1 && command2 && command3)
A bash scrpit is easy...
#!/bin/bash command1 command2 command3
Thank you. I knew it would be simple- but knowing it's simple and knowing what to do are two different things.
And from now on I'll know to use parantheses too. Sweet.
Last edited by pogeymanz (2008-09-26 00:05:36)
Offline
Don't do:
nohup $(commands...)
unless the commands are going to print as a result something that can be executed. For instance, this won't work:
nohup $(echo 10)
because it will turn into:
nohup 10
and you'll get an error message to the effect "command 10 not found". This would work:
nohup $(echo "echo 10")
but I don't know whether the nohup will kick in before the $(...) part has returned. For all I know, it could be that this:
nohup $(long-running-command)
will only have nohup-protection _after_ long-running-command has finished. You may have better luck with one of these constructions:
nohup ( command1; command2; command3 ) # or you could put '&&' between the commands, it won't matter
nohup { command1; command2; command3; }
I don't know whether they will work though, I haven't played around with this. Conceivably you might have to escape the '{'s or '('s. Or do this:
nohup bash -c "command1; command2; command3"
Well, there's no answer here but perhaps it'll help you find one, or prompt someone else who does know the answer...
Offline
Don't I have to have screen installed on the work computer to do what I'm doing? I don't have root privileges, so I can't install stuff.
If you have access to a compiler, compile your own and throw it in $HOME. I also cannot imagine any serious server NOT having screen...
[git] | [AURpkgs] | [arch-games]
Offline
Pages: 1