problem api when restart mikrotik

Salam alaikoum when I restart MikroTik remain API does not respond and continues to work automatically updated even hang Apache completely I want to know what is the solution to that problem

if ($API->connect('---,---,---,---','user','password')){
//your code
$API->disconnect();
}else{
die('<center><h1>NOT Respond</h1></center>');
}

:frowning: :frowning:

Instead of doing a direct “/system/reboot” call, add a scheduler script (“/system/scheduler/add”) to be triggered after a second or two. The scheduler script should first remove itself, and then reboot the router. In the meantime, PHP can disconnect successfully.