Sponsored Content
Top Forums Shell Programming and Scripting Killing a process that takes too long Post 302070697 by WeezelDs on Thursday 6th of April 2006 05:44:32 PM
Old 04-06-2006
Thanks...that script works great Smilie

Although I'm still having problems...I modified your perl script to be able to take command line arguments...is there a faster way than the way I did it?

The main problem however is that whenever I have php4's shell_exec command calling this script, nothing that is printed via perl's qx command gets returned to php4...i tried 'system($command)' rather than 'qx($command)', but that doesn't help...interestingly though, 'print system($command)' returns a -1 to php, but from a terminal, all of those run the program as desired...

how can i get shell_exec to see output from a call to qx?...is qx opening a new stream each time it is called or something?

here's my perl modified script:

Code:
#!/usr/bin/perl -w

# Run my_program w/ the given arguments.  If my_program is still running 
# after the specified number of seconds, kill it, and tell the user.

my $timeout = 5; # 5 second timeout

eval {
  local $SIG{ALRM} = sub { die "alarm\n" };
  alarm $timeout;
  $command = "./my_program";
  foreach $argnum (0 .. $#ARGV) {
    $command .= " $ARGV[$argnum]";
  }
  print qx($command);
  alarm 0;
};

if($@){
  die unless $@ eq "alarm\n";
  print "timeout\n";
  qx(ps -ef | grep pokenum | egrep -v " grep | vi | more | cat | pg | egrep " | awk '{print \$2}' | xargs kill );
}

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Interrupt signal Control C takes too long to terminate a process

I have a process to terminate, and when keying Control C/ kill -int , it takes 15 minutes to half an hour to terminate the process. I've tried using kill -2, or keying control c twice, however the process seem to be killed abruptly, without writing into the log file. So the only way in order to... (8 Replies)
Discussion started by: paqui
8 Replies

2. Linux

it takes long time to login on server

Hi, I am trying to login using ssh on Red Hat Linux 5 server, The password appears immediately but after I enter the password it takes about 90 seconds to login completely. Please suggest what changes require? Regards, Manoj (4 Replies)
Discussion started by: manoj.solaris
4 Replies

3. Shell Programming and Scripting

Finding the age of a unix process, killing old processes, killing zombie processes

I had issues with processes locking up. This script checks for processes and kills them if they are older than a certain time. Its uses some functions you'll need to define or remove, like slog() which I use for logging, and is_running() which checks if this script is already running so you can... (0 Replies)
Discussion started by: sukerman
0 Replies

4. UNIX for Dummies Questions & Answers

Changing Password process takes a long time

We are running unix. After a reboot of the server we have found that changing password takes a long time. if type in passwd "username" you can type in the 1st instance of the password , press enter , then it will wait for about 3 minutes before bringing up the confirm password line typing it in... (4 Replies)
Discussion started by: AIXlewis
4 Replies

5. Shell Programming and Scripting

sort takes a long time

Dear experts I have a 200MG text file in this format: text \tab number I try to sort using options -fd and it takes very long! is that normal or I can speed it up in some ways? I dont want to split the file since this one is already splitted. I use this command: sort -fd file >... (12 Replies)
Discussion started by: voolek
12 Replies

6. UNIX and Linux Applications

database takes long time to process

Hi, we currently having a issue where when we send jobs to the server for the application lawson, it is taking a very long time to complete. here are the last few lines of the database log. 2012-09-18-10.35.55.707279-240 E244403536A576 LEVEL: Warning PID : 950492 ... (1 Reply)
Discussion started by: techy1
1 Replies

7. UNIX for Advanced & Expert Users

Find command takes too long to complete

Hi, Below is my find command find /opt/app/websphere -name myfolder -perm -600 | wc -l At time it even takes 20 mins to complete. my OS is : SunOS mypc 5.10 Generic_150400-09 sun4v sparc SUNW,T5440 (10 Replies)
Discussion started by: mohtashims
10 Replies

8. Shell Programming and Scripting

Find command takes long

Hi, I am trying to search for a Directory called "mont" under a directory path "/opt/app/var/dumps" Although "mont" is in the very parent directory called "dumps" i.e "/opt/app/var/dumps/mont" and it can never be inside any Sub-Directory of "dumps"; my below find command which also checks... (5 Replies)
Discussion started by: mohtashims
5 Replies

9. Shell Programming and Scripting

Killing the process if running for long time in script

I am running a script which will read the data from fail line by line and call the Java program by providing the arguments from the each line. The Java code is working fast for few records and for some records its getting hanged not providing response for morethan one hour. Currently am... (4 Replies)
Discussion started by: dineshaila
4 Replies

10. Shell Programming and Scripting

Script takes too long to complete

Hi, I have a lengthy script which i have trimmed down for a test case as below. more run.sh #!/bin/bash paths="allpath.txt" while IFS= read -r loc do echo "Working on $loc" startdir=$loc find "$startdir" -type f \( ! -name "*.log*" ! -name "*.class*" \) -print | while read file do... (8 Replies)
Discussion started by: mohtashims
8 Replies
vzeventd(8)							    Containers							       vzeventd(8)

NAME
vzeventd - the OpenVZ events daemon. SYNOPSIS
vzeventd [-v] [-d] vzeventd -h DESCRIPTION
This daemon takes care of events sent by the OpenVZ kernel (via a netlink socket) and performs required actions associated with those events, by running specific scripts. Every event received contains a container ID, which is passed to the script as VEID environment vari- able. Current list of known events and associated vzeventd actions are: start Ignore. stop Run /usr/lib/vzctl/scripts/vzevent-stop. This script takes care of removing ARP and routing records for the given CT from CT0. mount Ignore. umount Ignore. reboot Run /usr/lib/vzctl/scripts/vzevent-reboot. This script takes care of rebooting a given CT. OPTIONS
-v Increase verbosity (can be used multiple times). -d Debug mode (do not daemonize, run in foreground). -h Display help and exit. EXIT STATUS
Returns 0 upon success. LICENSE
Copyright (C) 2010-2011, Parallels, Inc. Licensed under GNU GPL. AUTHOR
This manual page was initially written by Thorsten Schifferdecker <tsd@debian.systs.org> for the Debian GNU/Linux system (but may be used by others). OpenVZ 28 Jun 2011 vzeventd(8)
All times are GMT -4. The time now is 01:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy