0

Job's running too long, but don't want to terminate it. Before sending the process to background, I usually use ctrl-z in any tmux panel/window wihtout any problem, but for unknown reasons to me, this key combination suddenly stopped working for that particular panel. ctrl-z seems to work on other tmux panels though.

The job's currently running:

for f in *.webm; do ffmpeg -fflags +genpts -i "$f" -map 0 -s hd1080 -c:v libx264 -preset slower -crf 18 -b:a 64k "${f%.webm}".mp4; done

Any particular reason why ctrl-z would suddenly stop working?

Faxopita
  • 83
  • 1
  • 9
  • Did you enter this entire command directly? If so, my wild guess is that `for f in *.webm` is shell builtin and is thus not suspendable. – John Gordon Apr 11 '23 at 00:05
  • Yes. Just tested. I still got the same issue when not looping with `for`. The reason I got the issue might be the fact I did, after running the above command, these steps in the following order : 1) ctrl-Z (which paused well), 2) input `bg` (which made FFmpeg still prints on stdout), then ctrl-Z again (which does no longer do anything). I tried ctrl-C and that key combination too does not work. As though sending a process that outputs to stdout, into the background, deactivates any subsequent ctrl-key combination. – Faxopita Apr 11 '23 at 00:24
  • 1
    keys like ctrl-c/ctrl-z only affects **foreground** jobs/processes. – pynexj Apr 11 '23 at 06:34
  • Clear. After executing `bg` I was lured into believing FFmpeg was still a foreground process (due to FFmpeg still outputting to _stdout_). The sensible way to manage jobs that output to default screen, I believe, is to redirect all messages to some logfile—e.g. `> ffmpeg.log 2>&1`—that I would later inspect live from another session/panel using `tail -f ffmpeg.log`. Now, after executing `bg` from where I ran FFmpeg, the command prompt is freed. The reason I wanted to get back my prompt (in the panel running FFmpeg) was to run another cmd that would pause the conversion process after some time. – Faxopita Apr 11 '23 at 21:21

1 Answers1

1

Based on your comment, the bg command you entered made the command become a separate job, so it wouldn't respond to the usual ctrl commands. If it is still the most recent command, you can run fg to bring it back to the foreground to be able to pause it with ctrl-z again.

Otherwise, I'd recommend doing something like

ps -aux | grep ffmpeg

to get the PID of the process. Once you have that, you can stop, continue or terminate the process with the kill command.

p.s. If you plan to have long-running jobs in the future, you might want to consider using nohup and/or redirecting the output to a file.

Plonetheus
  • 704
  • 3
  • 11