Can anyone provide a simple example of running a system command in the background when a button is clicked.
eg: when this is clicked:
<button onclick="startprocess">Start</button>
run
$var = system('tail -f /mail.log > /download/mail.log 2>&1 & echo $!');
Thanks
html :
<button id="run_system">Start</button>
js :
$('#run_system').on('click', function() {
$.ajax({
url : 'run.php'
}).done(function(data) {
console.log(data);
});
});
run.php :
<?php
echo shell_exec('tail -f /mail.log > /download/mail.log 2>&1 & echo $!');
?>