Sending an interrupt in a script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sending an interrupt in a script?
# 1  
Old 09-20-2008
Sending an interrupt in a script?

Is it possible to sent a ^C interrupt via the command line? For example if I want to tail a log for 10 minutes at a time, kill the tail and then start it again is there a way to go about that? I would imagine there would be some way to do it by finding and killing the PID, but I'm curious if there's another way.

All I want is to be able to do a one liner like:

Code:
while true;do tail -f n2bb.log|grep 0x12|nl;sleep 600;<whatever kills the tail>;done

# 2  
Old 09-21-2008
Maybe something like:
_kill() { sleep 10m; pkill -9 -f 'tail -f /path/to/n2bb.log'; }; _tail() { _kill & \
tail -f /path/to/n2bb.log|grep 0x12|nl; _tail; }; _tail
May look odd but still is a oneliner.
# 3  
Old 09-21-2008
Quote:
Originally Posted by unSpawn
Maybe something like:
_kill() { sleep 10m; pkill -9 -f 'tail -f /path/to/n2bb.log'; }; _tail() { _kill & \
tail -f /path/to/n2bb.log|grep 0x12|nl; _tail; }; _tail
May look odd but still is a oneliner.
Hmmm, I'll have to take a look into something like that. Not sure if thats the directiion want to go with this...but as there don't seem to be a lot of options at the moment...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

Alarm interrupt and multithreading

Hi Friends any know how became a friend in this Android Programming Language (0 Replies)
Discussion started by: ljarun
0 Replies

2. UNIX for Advanced & Expert Users

Is there any shell command to show which interrupt handler handle which interrupt number?

Hi, all: Is there any shell command to show which interrupt handler handle which interrupt number in the system? li,kunlun (5 Replies)
Discussion started by: liklstar
5 Replies

3. UNIX for Advanced & Expert Users

Interrupt storm detected on "irq 20" throttling interrupt source

I receive the following warning messages on a very new machine which has FreeBSD 8.1 x64 installed on it: Interrupt storm detected on "irq 20" throttling interrupt source It is unclear what this means and what its origins are (motherboard? CPU? RAM?). I can start the desktop and the message is... (4 Replies)
Discussion started by: figaro
4 Replies

4. Shell Programming and Scripting

How to generate cntl+c interrupt through script?

Hi all, can anyone tell me how to generate control+c interrupt through shell script. (2 Replies)
Discussion started by: rohitmahambre
2 Replies

5. UNIX for Advanced & Expert Users

hunting down for software interrupt causes

Hi, i have an rhel box with around 20 %soft every 2 seconds. The box is idle. How do i start hunting down what's causing this? i believe /proc/interrupts is hardware related, procinfo is basically the same. where else can i look? thanks, Marc (5 Replies)
Discussion started by: marcpascual
5 Replies

6. Shell Programming and Scripting

help me in sending parameters from sqlplus script to unix shell script

Can anybody help me out in sending parameters from sql*plus script to unix shell script without using flat files.. Initially in a shell script i will call sql*plus and after getting some value from some tables, i want that variable value in unix shell script. How can i do this? Please tell me... (2 Replies)
Discussion started by: Hara
2 Replies

7. UNIX for Dummies Questions & Answers

timer interrupt

hello all since a process running in kernel mode cannnot be preempted by any other process what would be the status of Timer interrupt that occurs when the time quantum of a process is elapsed? thanks (2 Replies)
Discussion started by: compbug
2 Replies

8. UNIX for Advanced & Expert Users

Interrupt level 14 woes

Hi there, My first post here. Currently, i have been experiencing this error quite frequently on a ultra5 com. Things i have done is changing a new hdd and mem modules but i still encounter this error. Some messages from the var/adm WARNING: uncorrectable error from pci0 (upa mid 0) during... (0 Replies)
Discussion started by: kerwen
0 Replies

9. UNIX for Dummies Questions & Answers

erase and interrupt keys

This is on our Ultra 5/10 Sparc with Solaris 9. I need to store the following (stty) keys in the .profile and /etc/profile files as shown here. erase "Back Space Key" Interrupt "Ctrl + C" I need the exact syntax/procudure as I have to set these two keys whenever I login to the terminal... (1 Reply)
Discussion started by: chrs0302
1 Replies

10. UNIX for Advanced & Expert Users

Trapping Interrupt From 'ulimit'

I want to know the interrupt passed to a process through 'ulimit' I am running a process which gets killed when the 'ulimit -t' reaches. But after killing the process I want to start another process which would send a message or do some clean up or anything at all. To do the same I am... (5 Replies)
Discussion started by: mrnuttynuts
5 Replies
Login or Register to Ask a Question