4 added formatting and a longer explanation of turning this script into a darmon
source | link

A variant of @l0b0's answer:

dmesg --follow | awk '
   /BUG: workqueue lockup/  { system ("killall someprocessname") ; rem="done at each occurrence. You could add further things, like print to a logfile, etc.,"
        }'

This let's awk do the looping, which has some advantages:

  • it will work until that process dies.
  • It also do not call more than 1 killall per occurence of the searchstring "BUG: workqueue lockup"  , which improves upon the other answer.  

To test: You can put this into a script named thescript, and do nohup thescript &, so that thescript will keep running even after you quit your session.

Once you are satisfied it works, kill it, and then you can (instead of running it each time in a shell with nohup) transform it into a daemon script that you can then have started in your current runlevel.

ie: using another script as a model (you need to have at least the start, stop and status sections), you can modify thescript appropriately and then place it within /etc/rc.d/init.d, and have a symlink to it named Sxxthescript under the appropriate(s) /etc/rc.d/rcN, N being a number for your normal runlevel (see the top lines of who -a to know the current run-level). And have the appropriate Kxxthescript symlinks too, in every (or almost every) runlevels, so that the script is appropriately killed when switching runlevels.

Or do "the appropriate things" to have it run/stopped via systemd or any equivalent system your distribution uses.

A variant of @l0b0's answer:

dmesg --follow | awk '
   /BUG: workqueue lockup/  { system ("killall someprocessname") ; rem="done at each occurrence. You could add further things, like print to a logfile, etc.,"
        }'

This let's awk do the looping, which has some advantages:

  • it will work until that process dies.
  • It also do not call more than 1 killall per occurence of the searchstring "BUG: workqueue lockup"  .  

To test: You can put this into a script named thescript, and do nohup thescript &, so that thescript will keep running even after you quit your session.

Once you are satisfied it works, kill it, and then you can (instead of running it each time in a shell with nohup) transform it into a daemon script that you can then have started in your current runlevel.

ie: using another script as a model (you need to have at least the start, stop and status sections), you can modify thescript appropriately and then place it within /etc/rc.d/init.d, and have a symlink to it named Sxxthescript under the appropriate(s) /etc/rc.d/rcN, N being a number for your normal runlevel (see the top lines of who -a to know the current run-level). And have the appropriate Kxxthescript symlinks too, in every (or almost every) runlevels, so that the script is appropriately killed when switching runlevels.

Or do "the appropriate things" to have it run/stopped via systemd or any equivalent system your distribution uses.

A variant of @l0b0's answer:

dmesg --follow | awk '
   /BUG: workqueue lockup/  { system ("killall someprocessname") ; rem="done at each occurrence. You could add further things, like print to a logfile, etc.,"
        }'

This let's awk do the looping, which has some advantages:

  • it will work until that process dies.
  • It also do not call more than 1 killall per occurence of the searchstring "BUG: workqueue lockup", which improves upon the other answer.

To test: You can put this into a script named thescript, and do nohup thescript &, so that thescript will keep running even after you quit your session.

Once you are satisfied it works, kill it, and then you can (instead of running it each time in a shell with nohup) transform it into a daemon script that you can then have started in your current runlevel.

ie: using another script as a model (you need to have at least the start, stop and status sections), you can modify thescript appropriately and then place it within /etc/rc.d/init.d, and have a symlink to it named Sxxthescript under the appropriate(s) /etc/rc.d/rcN, N being a number for your normal runlevel (see the top lines of who -a to know the current run-level). And have the appropriate Kxxthescript symlinks too, in every (or almost every) runlevels, so that the script is appropriately killed when switching runlevels.

Or do "the appropriate things" to have it run/stopped via systemd or any equivalent system your distribution uses.

3 added formatting and a longer explanation of turning this script into a darmon
source | link

A variant of @l0b0's answer:

dmesg --follow | awk '
   /BUG: workqueue lockup/  { system ("killall someprocessname") ; rem="done at each occurrence. You could add further things, like print to a logfile, etc.,"
        }'

This let's awk do the looping, and it will work until that process dies. It also do not call more tham one killall per occurence of the searchstring. And If youwhich has some advantages:

  • it will work until that process dies.
  • It also do not call more than 1 killall per occurence of the searchstring "BUG: workqueue lockup" .

To test: You can put this into a script named thescript, and 'nohup thescript &'do nohup thescript &, thescriptso that thescript will runkeep running even after you quit your session. 

Once you are satisfied it works, kill it, and then you can (instead of runjingrunning it inbaeach time in a shell with nohuonohup) maketransform it into a deamon scriptdaemon script that you can then have started in your current runlevel.

ie: using another script as a model (.you need to have at least the start, stop and status sections), you can modify thescript appropriately and then place it within /etc/rc.d/init.d, and have a symlink to it named Sxxthescript under the appropriate(s) /etc/rc.d/rcN, N being a number for your normal runlevel (see the top lines of who -a to know the current run-level). And have the appropriate Kxxthescript symlinks too, in every (or almost every) runlevels, so that the script is appropriately killed when switching runlevels. or use

Or do "the appropriate things" to have it run/stopped via systemd?) or any equivalent system your distribution uses.

A variant of @l0b0's answer:

dmesg --follow | awk '
   /BUG: workqueue lockup/  { system ("killall someprocessname") ; rem="done at each occurrence. You could add further things, like print to a logfile, etc.,"
        }'

This let's awk do the looping, and it will work until that process dies. It also do not call more tham one killall per occurence of the searchstring. And If you put this into a script and 'nohup thescript &', thescript will run even after you quit your session. Once you are satisfied it works, you can (instead of runjing it inba shell with nohuo) make it a deamon script started in your current runlevel (... or use systemd?)

A variant of @l0b0's answer:

dmesg --follow | awk '
   /BUG: workqueue lockup/  { system ("killall someprocessname") ; rem="done at each occurrence. You could add further things, like print to a logfile, etc.,"
        }'

This let's awk do the looping, which has some advantages:

  • it will work until that process dies.
  • It also do not call more than 1 killall per occurence of the searchstring "BUG: workqueue lockup" .

To test: You can put this into a script named thescript, and do nohup thescript &, so that thescript will keep running even after you quit your session. 

Once you are satisfied it works, kill it, and then you can (instead of running it each time in a shell with nohup) transform it into a daemon script that you can then have started in your current runlevel.

ie: using another script as a model (you need to have at least the start, stop and status sections), you can modify thescript appropriately and then place it within /etc/rc.d/init.d, and have a symlink to it named Sxxthescript under the appropriate(s) /etc/rc.d/rcN, N being a number for your normal runlevel (see the top lines of who -a to know the current run-level). And have the appropriate Kxxthescript symlinks too, in every (or almost every) runlevels, so that the script is appropriately killed when switching runlevels.

Or do "the appropriate things" to have it run/stopped via systemd or any equivalent system your distribution uses.

2 added 81 characters in body; added 166 characters in body
source | link

A variant of @l0b0's answer:

dmesg --follow | awk '
   /BUG: workqueue lockup/  { system ("killall someprocessname") ; rem="done at each occurrence. You could add further things, like print to a logfile, etc.,"
        }'

This let's awk do the looping, and it will work until that process dies. It also do not call more tham one killall per occurence of the searchstring. And If you put this into a script and 'nohup thescript &', thescript will run even after you quit your session. Once you are satisfied it works, you can (instead of runjing it inba shell with nohuo) make it a deamon script started in your current runlevel (... or use systemd?)

A variant of @l0b0's answer:

dmesg --follow | awk '
   /BUG: workqueue lockup/  { system ("killall someprocessname") ; rem="done at each occurrence. You could add further things, like print to a logfile, etc.,"
        }'

This let's awk do the looping, and it will work until that process dies. If you put this into a script and 'nohup thescript &', thescript will run even after you quit your session.

A variant of @l0b0's answer:

dmesg --follow | awk '
   /BUG: workqueue lockup/  { system ("killall someprocessname") ; rem="done at each occurrence. You could add further things, like print to a logfile, etc.,"
        }'

This let's awk do the looping, and it will work until that process dies. It also do not call more tham one killall per occurence of the searchstring. And If you put this into a script and 'nohup thescript &', thescript will run even after you quit your session. Once you are satisfied it works, you can (instead of runjing it inba shell with nohuo) make it a deamon script started in your current runlevel (... or use systemd?)

1
source | link