1

Is it possible to "call" a background process output to be shown in the terminal?

Example: cron starts apt-get to update the system and I want to see the output of apt-get

1

Not really. There are tools that can detach a process from its output file and attach it to the current terminal — see How can I disown a running process and associate it to a new screen shell?. However:

  • These tools operate via a debugging interface (ptrace) and modify the execution of the program in an underhanded way. This can crash some programs.
  • If it works, the output will be on the terminal instead of the log file where it's supposed to go, not in addition to the log file.
  • The output emitted before running the tool will be in the log file only.

The output of a cron job will be logged somewhere: either the script in the crontab redirects the output to a file, or cron will send the output to the administrator by email. Check the crontab entry to see where the output goes.

On Linux, you can check where the output of a process goes by looking at its file descriptors in /proc/PID/fd/. File descriptor 1 is standard output and 2 is standard error.

0

I don't think that is possible. That would assume the process knows how to handle this situation and would reopen stdin/stdout/stderr.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.