Sponsored Content
Top Forums Shell Programming and Scripting Send ctrl-C signal using bash script. Post 302965418 by jim mcnamara on Thursday 28th of January 2016 03:12:12 PM
Old 01-28-2016
Control/c generates a sigint signal so lets try this - assume your script is called perf.shl

Code:
  /path/to/perf.shl  > perf.log &   # create a child process
  export pid=$!
  while [ kill -0 $pid 2>/dev/null -eq 0 ] # check the child process exists.
  do      
       sleep 10   # wait 10 seconds -- you change this to what you need
       kill -2  $pid 2>/dev/null   # sigint to child process --ctrl/c
  done

perf is based on Brandon Gregg's dtrace which starts when you execute it, then runs until ctrl/c is received then dumps data.
So. You may not really want a 10 second sleep.
This User Gave Thanks to jim mcnamara For This Post:
 

10 More Discussions You Might Find Interesting

1. AIX

Disable ctrl-c,ctrl-d,ctrl-d in ksh script

I wrote a ksh script for Helpdesk. I need to know how to disable ctrl-c,ctrl-z,ctrl-d..... so that helpdesk would not be able to get to system prompt :confused: (6 Replies)
Discussion started by: wtofu
6 Replies

2. Shell Programming and Scripting

Ctrl-C signal propagation

Hello I have a master startup script (let's call it myScript) that displays a menu from which the user can start/stop several instances of a server. When I issue the start command for one of the servers from the menu and then exit myScript through the provided mechanism (enter "q" in this case),... (2 Replies)
Discussion started by: EvilBoz
2 Replies

3. Shell Programming and Scripting

How to send SIGNAL to the thread?

Hello, I have to send SIGSEGV to the thread. What is the simplest and efficient way to do that? (6 Replies)
Discussion started by: Rahulpict
6 Replies

4. Shell Programming and Scripting

How to send Ctrl Break combination in Expect

Greetings, I am writing an Expect script to automate multiple processes on an HP-UX system. Everything has gone fine so far but I now have run into a problem. One of the processes that I'm trying to automate requires the key combination of ctrl break and I have so far been unable to figure out... (1 Reply)
Discussion started by: g_trueblood2000
1 Replies

5. Shell Programming and Scripting

ctrl c trapping signal

im trying to make a trap signal 2 (ctrl c) in a bash script if a user presses ctrl c while running the script it should display an error message but not quit the bash script just yet. User will have to press "enter" to quit This is what i have so far #trap trap_control 2 #while true #do... (6 Replies)
Discussion started by: gangsta
6 Replies

6. Shell Programming and Scripting

ctrl-c in bash script - Programming

Hi All, I need to place a ctrl-c interrupt in a bash script, there is no other way, it has to be done :) can someone please advise how would I go about this? i want to use ctrl c in below code, after the code excution of just 1 min or 1sec java Cspsamp 111.19.5.172 7025 rd1... (6 Replies)
Discussion started by: aish11
6 Replies

7. Shell Programming and Scripting

How to handle CTRL+Z or CTRL+C in shells script?

Hi, while executing shell script, in the middle of the process, if we kill the shell script( ctrl+z or ctrl+c), script will be killed and the files which using for the script will be in the folder. How to handle those scenarios. Is there any possibilities, if user breaks the script, I need to... (3 Replies)
Discussion started by: ckchelladurai
3 Replies

8. AIX

Send ctrl+C in expect script

Hi, Am trying to transfer file via FTP using expect script from server to client i need to interrupt the file transfer between server and client Please help what should used in expect code.. I used send "ctrl+c\r" expect "Aborted" but that didnt work.. I need what should... (3 Replies)
Discussion started by: Priya Amaresh
3 Replies

9. Shell Programming and Scripting

Vi : Is it possible to send ctrl + d signal from a file made with vi and executing it.

Hi Experts, Is it possible to send ctrl + d signal from a inside a file made with vi, using Ctrl V , Esc and 004 , escape sequence. Since : 004 should exit the script if executed. Is this something possible. I am trying with vi , I put this code ^ , and trying to execute it but... (4 Replies)
Discussion started by: rveri
4 Replies

10. Shell Programming and Scripting

Expect command to send the user input enter or ctrl+c

Hey All, I am writing one script using expect, that script which is used in spawn will accepts only 1. Enter 2. Ctrl+c Press Control-C to exit, Enter to proceed. Could some one share some thoughts to send the above user inputs in linux expect block ? Thanks, Sam (0 Replies)
Discussion started by: SCHITIMA
0 Replies
PERF-KVM(1)							    perf Manual 						       PERF-KVM(1)

NAME
perf-kvm - Tool to trace/measure kvm guest os SYNOPSIS
perf kvm [--host] [--guest] [--guestmount=<path> [--guestkallsyms=<path> --guestmodules=<path> | --guestvmlinux=<path>]] {top|record|report|diff|buildid-list} perf kvm [--host] [--guest] [--guestkallsyms=<path> --guestmodules=<path> | --guestvmlinux=<path>] {top|record|report|diff|buildid-list|stat} 'perf kvm stat [record|report|live] [<options>] DESCRIPTION
There are a couple of variants of perf kvm: 'perf kvm [options] top <command>' to generates and displays a performance counter profile of guest os in realtime of an arbitrary workload. 'perf kvm record <command>' to record the performance counter profile of an arbitrary workload and save it into a perf data file. If both --host and --guest are input, the perf data file name is perf.data.kvm. If there is no --host but --guest, the file name is perf.data.guest. If there is no --guest but --host, the file name is perf.data.host. 'perf kvm report' to display the performance counter profile information recorded via perf kvm record. 'perf kvm diff' to displays the performance difference amongst two perf.data files captured via perf record. 'perf kvm buildid-list' to display the buildids found in a perf data file, so that other tools can be used to fetch packages with matching symbol tables for use by perf report. 'perf kvm stat <command>' to run a command and gather performance counter statistics. Especially, perf 'kvm stat record/report' generates a statistical analysis of KVM events. Currently, vmexit, mmio and ioport events are supported. 'perf kvm stat record <command>' records kvm events and the events between start and end <command>. And this command produces a file which contains tracing results of kvm events. 'perf kvm stat report' reports statistical data which includes events handled time, samples, and so on. 'perf kvm stat live' reports statistical data in a live mode (similar to record + report but with statistical data updated live at a given display rate). OPTIONS
-i, --input= Input file name. -o, --output Output file name. --host= Collect host side performance profile. --guest= Collect guest side performance profile. --guestmount=<path> Guest os root file system mount directory. Users mounts guest os root directories under <path> by a specific filesystem access method, typically, sshfs. For example, start 2 guest os. The one's pid is 8888 and the other's is 9999. #mkdir /guestmount; cd/guestmount #sshfs -o allow_other,direct_io -p 5551 localhost:/ 8888/ #sshfs -o allow_other,direct_io -p 5552 localhost:/ 9999/ #perf kvm --host --guest --guestmount=~/guestmount top --guestkallsyms=<path> Guest os /proc/kallsyms file copy. perf kvm' reads it to get guest kernel symbols. Users copy it out from guest os. --guestmodules=<path> Guest os /proc/modules file copy. perf kvm' reads it to get guest kernel module information. Users copy it out from guest os. --guestvmlinux=<path> Guest os kernel vmlinux. STAT REPORT OPTIONS
--vcpu=<value> analyze events which occures on this vcpu. (default: all vcpus) --event=<value> event to be analyzed. Possible values: vmexit, mmio, ioport. (default: vmexit) -k, --key=<value> Sorting key. Possible values: sample (default, sort by samples number), time (sort by average time). -p, --pid= Analyze events only for given process ID(s) (comma separated list). STAT LIVE OPTIONS
-d, --display Time in seconds between display updates -m, --mmap-pages= Number of mmap data pages. Must be a power of two. -a, --all-cpus System-wide collection from all CPUs. -p, --pid= Analyze events only for given process ID(s) (comma separated list). --vcpu=<value> analyze events which occures on this vcpu. (default: all vcpus) --event=<value> event to be analyzed. Possible values: vmexit, mmio, ioport. (default: vmexit) -k, --key=<value> Sorting key. Possible values: sample (default, sort by samples number), time (sort by average time). --duration=<value> Show events other than HLT that take longer than duration usecs. SEE ALSO
perf-top(1), perf-record(1), perf-report(1), perf-diff(1), perf-buildid-list(1), perf-stat(1) perf 06/30/2014 PERF-KVM(1)
All times are GMT -4. The time now is 04:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy