How to Pause/Resume a process in Linux
Asked Answered
C

2

28

I record my program until it closes.

Start Command:

cvlc screen:// --screen-left=0 --screen-top=0 --screen-width=1280 --screen-height=960 --screen-fps=30 \
--sout '#transcode{vcodec=mp2v, vb=800, scale=1, acodec=none}:file{mux=ts, dst=your_video_path_to_be_saved}'

Stop Command:

kill -9 pgrep vlc

That works well, now I need to implement pause method to this program. I need to kill program at pause method then start it on resume method and append new video to older one. How can i do it?

VLC Wiki: Merge

Cynth answered 8/1, 2015 at 16:30 Comment(2)
Why is this tagged c++?Contestant
Doesn’t the ‘stop’ command need to be kill -9 $(pgrep vlc) - or perhaps better, use pidof instead of pgrep? Or you can do away with the process searching step and use killall.Opening
S
59

To pause the process

kill -STOP <PID>

To resume it

kill -CONT <PID>
Sw answered 8/1, 2015 at 16:33 Comment(1)
Just for pedantry, the signal names this sends to the process in question are SIGSTOP and SIGCONT.Dutiful
J
21

Ctrl + z (SIGTSTP) from the shell stops (nowaday we will probably use the term "suspend", which the man page of bash does) a process. The process can be continued ("resumed") with the commands fg (in foreground) or bg (in background).

kill -9 doesn't stop a process, it kills it (SIGKILL). I mention it, because wording here is ambiguous.

Jareb answered 9/1, 2015 at 9:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.