I want a script which automates the running of big mathematical computing jobs on a remote machine. Currently I do this:
sshinto remote machine; run matlab script- periodically check in to see if job is done yet
- when job is done, I manually
scpthe files containing the results back to my home machine.
I tried to use these kind of lines in my script to do this job (note the script runs on my machine):
ssh nohup matlab -r theScript; exit;
scp remote@~/files ~/files
This doesn’t work. After a while the ssh session ends and the script just proceeds to do the scp, even though the job is not finished yet and the files don’t exist yet.
I think what I need to do is check periodically whether the job is done, perhaps by ssh’ing in periodically and reading the nohup.out file looking for a DONE! signal using grep. Then when I see that, copy the files back. But this seems complicated and I don’t know how to get the DONE! message back to my computer to run a conditional on (if you see the DONE signal, do this stuff…) any ideas?
Yeah, the ssh could time out or something. So yeah, you best option is to poll. e.g.