0

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 &');

jay
  • 1
  • 2
  • 1
    You can use the kill command in PHP to terminate a process. For example, if the process ID of cpulimit is 1234, you can use the following command to kill it: exec('kill -9 1234'); – BhAvik Gajjar Jan 25 '23 at 11:13

0 Answers0