most of the it guys, me included, always face the situation like starting to delete or rsync some data in a ssh session, they realize that their isp is not so trusty or they have to go offline halfway through.
i would do the following actions in this situation
- cancel the process
- run it using nohup, or run it in virtual terminal using screen
what will you do if the building three procedure of the rsync takes 4 hours and after 3 hours you catch yourself on a idea that you've forgotten to run it using above mentioned methods. of course you can kill the process and rerun it but it will be time wasting.
when i were reading the bash reference manual in the section "7.1 job control basics" i found out that you were able to do that. there is the command called disown which helps you to do that.
here is the quote from manual concerning it:
disown [-ar] [-h] [jobspec ...]you can pause it (ctrl+z), background it (bg), and then disown it so it is protected from SIGHUP when you quit your ssh session.
Without options, each jobspec is removed from the table of active jobs. If the -h option is given, the job is not removed from the table, but is marked so that SIGHUP is not sent to the job if the shell receives a SIGHUP. If jobspec is not present, and neither the -a nor -r option is supplied, the current job is used. If no jobspec is supplied, the -a option means to remove or mark all jobs; the -r option without a jobspec argument restricts operation to running jobs.
watch the screen cast as an example
3 comments:
Very useful thing bro.
Thanks a lot !!!
And I suppose parent PID will become 1, right?
Yes, the parent pid will be init.
Post a Comment