php shell_exec, exec command timeout


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting php shell_exec, exec command timeout
# 1  
Old 10-16-2009
php shell_exec, exec command timeout

HI,

Does anybody know if its possible to execute a command through exec,
shell exec, system and if the program doesn't terminate in N seconds
returns control to PHP ?

reg,
research3

---------- Post updated 10-16-09 at 12:20 AM ---------- Previous update was 10-15-09 at 11:03 PM ----------

one of the solutions is:

Code:
<?php
exec("comand & sleep 3 ; kill $!");
?>

# 2  
Old 10-16-2009
Gently

Seems reasonable to me, but I'd do this:
Code:
exec("comand && (sleep 3 ; kill -TERM $!; sleep 1; kill -9 $!)");

This mimics the usual shutdown sequence: give the process a change to die gracefully (-TERM) but if it hangs, terminate with extreme prejudice (-9).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Linux find command seems to not transmit all the result to the '-exec command'

Hello. From a script, a command for a test is use : find /home/user_install -maxdepth 1 -type f -newer /tmp/000_skel_file_deb ! -newer /tmp/000_skel_file_end -name '.bashrc' -o -name '.profile' -o -name '.gtkrc-2.0' -o -name '.i18n' -o -name '.inputrc' Tha command... (3 Replies)
Discussion started by: jcdole
3 Replies

2. Shell Programming and Scripting

Mailx command timeout Issue

Hi All, I have a situation where we need to send out mails from our Unix server to different mailing ids inside our scripts.The mails are working fine.But we have occasional issues where we are getting time out errors from the SMTP server while sending out mails. Command that we are using... (3 Replies)
Discussion started by: DevotedPupil
3 Replies

3. Shell Programming and Scripting

Sqlplus with shell_exec(); PHP command

Hi, I need to run a PL/SQL Query from a distant oracle server in order to create spool files and send it to my own server, using a php script. I firstly created a SH script called myscript.sh #!/bin/bash echo "This script is working" sqlplus... (8 Replies)
Discussion started by: cgstag
8 Replies

4. Shell Programming and Scripting

command timeout in ksh

I probably read all the threads in almost all the forums for a solution to my need. I am a beginner in shell scripting and I dont have a perfect solution yet. Below is my code snippet. idql -n $REPOSITORY_NAME.$cs -Udmadmin -P"" -R$DM_SCRIPTS/test.api > /dev/null 2>&1 if ; then echo... (7 Replies)
Discussion started by: vishnudev1
7 Replies

5. Programming

PHP exec to restart mysqld

I want to do something very very bad. I want to create a button that restarts mysqld. Why is irrelevant for my issue. Here is my php script ... <?php if(isset($_POST)){ exec("sudo /etc/init.d/mysqld restart"); } ?> <form method="POST"> <input type="submit" name="restart"... (3 Replies)
Discussion started by: noPermissions
3 Replies

6. Shell Programming and Scripting

Command timeout from inside script.

Hi, I've written a very robust script to get an external IP address from 'behind' a router. It uses many web pages randomly choosing which one/ones to use at run time. The "fetch the web page containing the IP address" is handled by either wget or curl both of which have their 'max time for the... (6 Replies)
Discussion started by: gencon
6 Replies

7. Web Development

php shell_exec

Hey guys i've recently been getting into php programming and i became thinking was it possible to create a php script that would allow you to run a terminal from the browser page? All i've pretty much got so far is: $var = $_GET; $output = php shell_exec($var); echo $output; ... (4 Replies)
Discussion started by: lordfirex
4 Replies

8. Shell Programming and Scripting

Help with PHP and shell_exec!!!

Hi, I've been working on a PHP script which is "supposed" to find an individuals weather based on their geolocation. This script uses "shell_exec". I have checked my syntax and it is correct, but there is still something missing; for when I call on the script using: <form action='/weather.php'... (15 Replies)
Discussion started by: o0110o
15 Replies

9. Shell Programming and Scripting

exec command

can any one pls explain the meaning of exec 1<&5 ?? its urgent (2 Replies)
Discussion started by: santosh1234
2 Replies

10. Shell Programming and Scripting

Can we timeout cd command

Hi All, I want to know whether we can timeout the cd command in unix. If we can how is it implemented? Suppose cd command hangs can we timeout the command. Please help (9 Replies)
Discussion started by: dipashre
9 Replies
Login or Register to Ask a Question