There is a code on the page that reads a text file and its contents are displayed on the page with auto-update. There is also a part of the PHP code, which for some reason is part of the ssh call, executes the command many times (this is the part of $ ssh-> exec ...). I see this from the result on the server, the resulting file is constantly being created for a new one. Most likely, it ($ ssh-> exec ...) is executed with an interval that is setInterval (readTextFile, 1000).

But why this is not happening.

<?php require __DIR__ . '/autoload.php'; use phpseclib\Net\SSH2; function date_range($first, $last, $step = '+1 day', $output_format = 'Ymd' ) { $dates = array(); $current = strtotime($first); $last = strtotime($last); while( $current <= $last ) { $dates[] = date($output_format, $current); $current = strtotime($step, $current); } return $dates; } $ssh = new SSH2('10.00.00.00'); if (!$ssh->login('dff', '1234')) { exit('Login Failed'); } $ssh->exec('nohup bash -c \'i=(2018-12-02 2018-12-03 2018-12-04 2018-12-05 2018-12-06 2018-12-07 2018-12-08 2018-12-09 2018-12-10); for i in ${i[@]}; do zgrep \'20181202_01594110012_2225132\' /home/log.${i}.zip; done > /home/result.txt\' >/dev/null 2>&1 & exit'); ?> <html> <head> <meta charset="utf-8"> <title>Поиск</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script> function readTextFile(file) { var x = document.getElementById("autoScroll").checked; //if autoscrool is checked if(x==true){ document.getElementById("textarea").scrollTop = document.getElementById("textarea").scrollHeight; //autoscroll } var filePath = "./tmp/Data.txt" $.ajax({ dataType: "text", success : function (data) { $("#textarea").load(filePath); } }); } setInterval(readTextFile, 1000); </script> <script> function copy() { let textarea = document.getElementById("textarea"); textarea.select(); document.execCommand("copy"); } </script> <script> $(function() { $( "#datepicker" ).datepicker({ dateFormat: "yy-mm-dd" , firstDay: 1 }); $( "#datepicker2" ).datepicker({ dateFormat: "yy-mm-dd" , firstDay: 1 }); }); </script> </head> <body> <form method="post" action=""> <p><b>Дата от:</b> <input type="text" NAME="DATE1" id="datepicker"></p> <p><b>Дата до:</b> <input type="text" NAME="DATE2" id="datepicker2"></p> <input type="checkbox" name="OPTION2[]" value="POV">POV<br> <input type="checkbox" name="OPTION2[]" value="SIB">SIB<br> <input type="checkbox" name="OPTION2[]" value="SZ">SZ<br> <input type="checkbox" name="OPTION2[]" value="UG">UG<br> <p><input type="submit" size="15" name="submit" Value="Искать"></p> </form> <textarea id="textarea" rows="15" cols="150" readonly autocomplete="off"></textarea> <br> <form> <label> <input type="checkbox" value="AutoScroll" id="autoScroll" label="Auto Scroll" checked> Авто-прокрутка</label> </form> <button onclick="copy()">Копировать</button> </body> </html> 
  • why every second run an AJAX request? and paired with setInterval, there is clearInterval (timerId), which you should probably hang on the success AJAX request? - sterx 3:16 pm
  • And how should it look like? Ajax is launched to display the contents of the file online. - Dima Kuzmin
  • > setInterval for what? update "#textarea" every second? - sterx pm
  • Yes. Maybe you can do something differently. - Dima Kuzmin
  • Well, actually this is the answer to your question - sterx

0