Hello
Can you please assist me in writing a script to redirect the output of asterisk -vvvr to a file( I used asterisk -vvvr > filename). With normal commands like tail, I am able to do it. But in the case of asterisk, once the process is started, I am not able to stop it from the script.
Thank you for your reply. The /var/log/asterisk/messages contains the entire log. I just wanted to split it say daily or say upto 5 mb size. The file name should contain time stamp. I am copying my script below.
Never use kill -9 in a context like this. It is a last resort, not a first choice.
The correct way of doing this is to move the /var/log/asterisk/full file then use rasterisk to send a logger command to asterisk. Details are left to the reader.
Have a look through the logger commands. There may be ones that make this even easier.
Wouldn’t it be more efficient just to parse the existing log file from Asterisk and storing the parsed output in separate files? I think doing a couple of grep/sed/awk commands would not be so hard … And you can make this parser script run as a cronjob that is excecuted every night.
Thanks for all your replies. I am a newbie to asterisk. So I don’t have the complete picture. What I just tried was to split the logs into smaller files say 5 MB so that I can store it in a safe location for future reference. I think What dejanst suggested is a nice idea. I will try that definitely
I’d strongly suggest looking at the contrib script, and if it doesn’t use logrotate, doing man logrotate. You will almost certainly get a cleaner, and more efficient, solution.
[quote=“malcolmd”]Ah, that’s not part of the Makefile until 1.6.0.
Cheers.[/quote]
Ok thanks. It was already installed. I did some configurations for daily rotate with rotate count 5.
/var/log/asterisk/messages {
daily
missingok
rotate 5
size 3000k
copytruncate
endscript
}
Do I have to add a cronjob in order to get it work? Size of my /var/log/messages crossed 3 mb. Still asterisk is writing to the same file. Did I forget some step