Reputation: 4677
I have some piped processes going on in the background that have been running for over a day now.
$ cmd | cmd | cmd | cmd | cmd > file
Is it possible to flush all the pipes so I can see the current state inside the file?
Upvotes: 2
Views: 178
Reputation: 101251
Compile
#include <stdio.h>
#include <unistd.h>
#include <sys/errno.h>
int main(int argc, char **argv){
fflush(NULL);
if (!errno) sync();
return errno;
}
to, say, fflush
and but it in ~/bin
or /opt/bin
or /usr/local/bin
depending on your personal preference and permissions, make sure this command is in your path and simply use it.
The fact that this (simple!) thing does not exist in the usual toolset suggests that it is rarely useful: in general this defeats attempts by the OS to be smart and makes things slow down. Worse, with an extended pipeline like the one you exhibit, it may flush the pipes in the "wrong" order leaving not much more certain of the current progress than you were before.
Upvotes: 2