Operating System - HP-UX
1753808 Members
7873 Online
108805 Solutions
New Discussion юеВ

Re: Output of dmesg with a simple script

 
SOLVED
Go to solution
Md.Shahabuddin
Advisor

Output of dmesg with a simple script

Hi,

I have to run dmesg after every 5 minutes, could u give me a simple script with do while and sleep variable, through which the output of dmesg should be displayed automatically after 5 minutes. I know i can do it with cron tab, but i want a simple do while execution. Thanks in advance.
5 REPLIES 5
Don Morris_1
Honored Contributor
Solution

Re: Output of dmesg with a simple script

while true^Jdo^Jdmesg -^Jsleep 300^Jdone

Lose the "-" if you really want full dmesg output (I wouldn't think you would, just what's new since last invocation).
Laurent Menase
Honored Contributor

Re: Output of dmesg with a simple script

typeset -i x=0
while :
do
x=$(date +%Y%m%d%H%M)
dmesg - >>$(( (x/5)*5 )).out
sleep 1
done

every 1 sec, it will get new dmesg and put it in a file named dateHM rounded to 5min.



Md.Shahabuddin
Advisor

Re: Output of dmesg with a simple script

HI Don,

Thanks a lot for your reply. I got my answer and it was perfect.
Bill Hassell
Honored Contributor

Re: Output of dmesg with a simple script

Are you trying to create a logfile for dmesg? If so, it is much easier to use dmesg and cron. There is a special option: "-"
This option tells dmesg to only show something happened since the last time dmesg - was run. And it will add a time stamp if there is anything new. Just put this line in crontab:

0,10,20,30,40,50 * * * * /sbin/dmesg - >> /var/adm/dmesg.log

Now you'll have all dmesg lines logged automatically.


Bill Hassell, sysadmin
Md.Shahabuddin
Advisor

Re: Output of dmesg with a simple script

Thanks a lot folk. I got the solution.