简体   繁体   中英

php script to kill shell 'sleep' process

I need to write some scripts for some automation work,

I put a php file on local apache server test.php

<?php
system("bash inform.sh");
?>

the content of inform.sh is:

#!/bin/bash
proc_id=`ps -ef|grep "sleep"|grep -v "grep"|awk '{print $2}'`
kill -9 $proc_id

I run sleep process on a shell, and open the php page on firefox : localhost/test.php but it doesn't kill the sleep process, if I run the php directly through shell, then it works what's wrong with this and how to deal with it? thanks

我使用以下shell命令,然后确定:

sudo -u apache sleep 2000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM