Long running script stops sending output to file Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Long running script stops sending output to file without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I have a script that I’m using to capture some status of the server at 10 second intervals.

The script is as follows:

for (( ; ; ))
    /usr/local/apache/bin/apachectl fullstatus
    sleep 10

And I am running the script using:

nohup /path/to/scriptname.sh | gzip > logfile.log.gz &

It will run in the background and keep running if I disconnect from ssh. However, after about 3-4 hours the output stops getting transferred to the logfile. The script is still running and shows up if I run ps -elf | grep scriptname, but the logfile does not update. Why does the output stop sending? Is this possibly a problem with the buffer?


The gzip file format has an 8-byte footer containing a CRC-32 checksum and uncompressed length of the data. The DEFLATE file format is block-oriented. The gzip program in the pipeline is almost certainly buffering up input to use in the next output block. The 8-byte footer won’t be written until after the long-running shell script exits, and gzip‘s stdin closes. I think you’ll have to wait for a long while to see if DEFLATE blocks aren’t periodically written to the log file.

We are here to answer your question about Long running script stops sending output to file - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji