how to kill cpulimit right after clamscan in php when both are running in background

61 Views Asked by At

I have switched as the user in linux using php code. I set cpulimit to 88% for clamscan and then scan /home/user or /home/user/mail recursively using clamscan.

As you can see both the exec codes below, both are running in background using '&' at the end.

If '$scan_path=/home/user' then cpulimit is not getting killed when I check in terminal using the command 'ps aux | grep cpulimit'.

But if '$scan_path=/home/user/mail' or '$scan_path=/home/user/public_html' then cpulimit gets killed after clamscan scanning is over.

PHP Code:

switch_user($user);

exec('cpulimit -l 88 -e clamscan &');

exec('clamscan --recursive '.$scan_path.' -l '.$log_file.' 2>&1 && pkill cpulimit &');

0

There are 0 best solutions below