How to close "screen" session from a script?
I am using screen to start a LONG running script on my server over an ssh connection. This works fine. I can see that the script is continuing to run after I disconnect from the screen session using Ctrl-A d. When the script is complete I can reconnect to the screen session and manually terminate it.
I would like to be able to terminate the screen session at the end of the script. I tried issuing an exit command at the end of the script. That did NOT work. Any ideas? TIA, Ken |
You could tack a "kill -9 PID" at the end of your script if you
can uniquely identify the screen instance you're firing up :} Cheers, Tink |
Thanks Tinkster,
I think that would be rather easy for one script running. My plan is to initiate 4 parallel scripts so I will have to do some investigation. If I KNEW which script would end last I could have it iterate and kill all "screen" processes. Or I could run the scripts serially. I am not sure which would be faster. Basically I am using dd if=/dev/urandom of=(partition I want to clear)/bigfile to do a quick and dirty wipe of free space. Well at least quick compared to using sfill -l -l which I computed would take 12 DAYS! I guess I need to fill up more of the 5 GB of storage on my server with crap so I have less free space to wipe :rolleyes: Ken |
You could conceivably fire of all processes; check them in a while loop w/
a 1-second sleep, and kill screen if they're all gone .... something like Code:
/path/to/script1 & No guarantee for completeness above ;D Cheers, Tink |
An alternative to the above would be to utilise the $! Special Var http://tldp.org/LDP/abs/html/internalvariables.html and track the actual pids of the created processes.
|
Thanks folks! I allowed two processes to run overnight (14 hours) and based on the progress they made I think I will have to run sequentially. That will make things easier.
Ken |
Out of curiosity: is this path to be wiped on an external USB device?
|
In answer to your curiosity... The system consists of:
A Dell Poweredge 400 SC server (Pentium 4; 2.33 GHz; 3 GB RAM) with the following hard drives (all SATA): Western Digital Caviar Black 1 TB Western Digital Caviar Green 1 TB Western Digital Caviar Green 1 TB Western Digital Caviar Green 2 TB The green drives are low power consumption and a little slow but not that slow. I think the limiting factor is the CPU which is consumed 100% by dd. I have had better results creating a file of say 1 GB with dd if=/dev/urandom and then copying the 1 GB files to the drive to be wiped from within a loop (cp to an incremented file name each time) until it runs out of space. Ken |
You could (to help the CPU) use a decent blocksize with dd ...
dd if=/dev/urandom of=/... bs=4096 Of course the problem may be the urandom usage. [edit] Scrap that - slow as. From urandoms man-page Quote:
byte file, and slap that over the devices in the loop ;} [/edit] Cheers, Tink |
Thanks! Good point. urandom is really slow. I had at one time played with copying various size files of random data to fill free space. Larger files seemed to be faster.
Ken |
All times are GMT -5. The time now is 07:50 PM. |