How to write the updated output of a continious running program to a file?
Hi,
I want to execute sipp Load scripts through a shell scripts. The sipp scripts will run more than 8 hrs continiously as per my requirment in the background. when i wrote the code in the shell as ./sipp a> mylogs.txt & It wrote the outputs of the ./sipp a to the mylogs.txt continiously.(i.e. it appends the updated output to the mylogs.txt in every 1 secs). Hence it increased the size of mylogs.txt file in every secs. What i need is it should only write the upadted output in every second from the begginging of file in stead of appending the things in every secs, which increase my file size. Please suggest a suitable code for it. Regards, Sanjay |
Quote:
Hi, I'm no coder... That said... some of my scripts print to a file when run, in order to not overwrite the old file, I set the name of the file to include the current time and date. for example, an rpm database list I like to diff from time to time... Code:
echo "run rpm -Va | grep "Unsatisfied dep" & send to /home/glenn/build/anote-rpm-Va-grep-Unsatisfied-dep-list-`date +%Y-%m-%d-%H`.txt" Quote:
HTH, Glenn Ps. I guess, that `"date" +...` is a BASH interpretation/implementation.(should work ;-)) This only updates every/any hour. It's possible to write a new file as fast as possible, maybe every second ( add -%M-%S) if the hardware can do it. |
Hi,
Thanks for your replay. It's fine. Every sec it will create a new file and writes the updated output. But i don't require the old files as it will increase the size and may hang my system after 8 to 10 hrs execution of my sipp script. So what i need is when it creates the new to write the updated output, it should delete automatically the previously created/old file as i don't require that files. Please suggest is there any suitable code for it? |
Quote:
Quote:
|
I have written the code as follows
#myscript.sh #!bin/sh cd /usr/bin; #flow1 nohup ./sipp 192.65.221.186:5060 -i 10.92.219.170 -p 5060 -sf PCP1.xml & pid_pcp1=$! #flow2 nohup ./sipp 192.65.221.186:5060 -i 10.92.219.171 -p 5060 -sf PCP2.xml & pid_pcp2=$! #flow3 nohup ./sipp 192.65.221.186:5060 -i 10.92.219.172 -p 5060 -sf PCP3.xml & pid_pcp3=$! #flow4 nohup ./sipp 192.65.221.186:5060 -i 10.92.219.173 -p 5060 -sf PCP3.xml & pid_pcp4=$! sleep n kill -SIGUSR1 $pid_pcp1 kill -SIGUSR1 $pid_pcp2 kill -SIGUSR1 $pid_pcp3 kill -SIGUSR1 $pid_pcp4 Actually my requirment is i have to start these sipp scripts for traffic generation at a time by using a shell script. Then i want to check their outputs whenever i need. After a specific duration i want to gracefully terminate the above flows. Starting and gracefully shut down is working fine. Only i am facing problem is that how can i check the updated ouput status of all flows whenever i need. If i started the above flows individually in different terminal then i can view the outputs of them in their respective terminals. But here as i have started them in background in one shell script then how can i check the individual output status of flows whenever i need. Please suggest how to do the same? Regards, Sanjay |
It would have been more efficient to state that sipp actually is sipp. This also means that executing
Code:
./sipp a> mylogs.txt & Code:
find /home/sanjay/sipp/logs -type f -name PCP\* -print0 | xargs -0 -iX rm -f 'X' Code:
find /home/sanjay/sipp/logs -type f -name PCP\*|while read ITEM; do [ -e "${ITEM}" ] && { fuser "${ITEM}" >/dev/null 2>&1||rm -f "${ITEM}"; }; done |
Hi,
I think man screen command will be helpful for me. I want to execute all the above 4 sipp commands simultaneously by starting one shell script. beacuse that is my requirment. Only thing is i want to see their screen outputs whenever i need. Please suggest how can i implement this "man screen" command for my code above to see the screen outputs of 4 sipp processes when ever i need individually or together? I was trying a lot to implement the man screen command for my code. But i am not able to get any idea. please suggest. Regards sanjay |
Quote:
|
All times are GMT -5. The time now is 06:47 AM. |