Last active
March 20, 2019 10:38
-
-
Save edmhs/2a2b8039a8baacd4ffe3267f91418588 to your computer and use it in GitHub Desktop.
Very old hack to run multiple php processes. Named "daksa" in translation from Latvian mean "Fork"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo date('Y-m-d H:i:s')."\n"; | |
// filename to run | |
$filename = "check_count.php"; | |
// max processes | |
$processes = 8;//rand(0,1); | |
$total = 0; | |
// get all active server php processes, exclude grep search record | |
exec("ps auxwww|grep php|grep -v grep", $output); | |
// print_r($output); | |
// match required script and count how many are running | |
foreach($output as $out){ | |
if (strpos($out,$filename) !== false) { | |
$total++; | |
} | |
} | |
echo $total." processes\n"; | |
# if running less then required, start new processes | |
if($total<$processes){ | |
run_proces($filename,($processes-$total)); | |
} | |
# start multiple processes function | |
function run_proces($filename,$count=1){ | |
$done = 0; | |
while($done<$count){ | |
exec("php /var/www/html/math/$filename > /dev/null 2>/dev/null &"); | |
echo "Runned another process \n"; | |
$done++; | |
sleep(2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment