Sample Header Ad - 728x90

How can I make my looping shell script pause after a loop by sending something like ctrl-z and then be continuable?

0 votes
2 answers
631 views
I have a shell script that loops over files. Processing each file can take several hours (it is CPU/GPU-limited). Sometimes I want to pause the execution at the end of a loop, when a file is finished processing, but then be able to resume later on, similar to how you can pause using ctrl-z and then fg, but I want it to finish the current loop before actually pausing/going into the background. Basically I want the script, when it receives a ctrl-z (or similar), to wait until it reaches a certain line before it halts. How do you achieve that?
Asked by d-b (2047 rep)
Jul 22, 2023, 07:49 PM
Last activity: Jul 23, 2023, 01:46 AM