Force reboot

Is it possible to force reboot on RouterOS? I have some Perl scripts that do various things in RouterOS, but when it try to reboot, the command times out-because of question: Reboot, y/n. is it possible to force reboot e.g that system do not ask that question?

Put it in a script.

/system reboot

Tested on RB532 and RB433

Doesn’t it still need the yes or no answered?

Yes, there is a question…hm is there a way to force reboot? :confused:

are you working via Telnet? then just send ‘/system reboot’ + + ‘y’

#!/usr/bin/perl

use Net::Telnet;#poziva se Telnet modul

#Inicijalizacija username-a i passworda
$username = 'admin';
$pass = 'password';

$telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die');
   $telnet->open('some ip'); 
   $telnet->login($username, $pass);
   $telnet->cmd('/system reboot' + <CR><LF> + 'y');

This the simple code and it returns me an error:

[root@localhost omer]# ./reboot.pl 
syntax error at ./reboot.pl line 12, near "LF>"
Execution of ./reboot.pl aborted due to compilation errors.

I’m not familiar with Perl, try

$telnet->cmd("/system reboot\ny");

Thank you…iy didn’t work. But forget perl…is there a way to force reboot in RouterOS from command line? Something like this:system force reboot… :confused:

add a script with “/system reboot” command, then use “/system script run reboot” ))

No of course not.

This is my script.

name="reboot" owner="hilton" 
     policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive 
     run-count=0 source=
       :delay 10s
       /system reboot

It works like a bomb whether run manually or via the scheduler.

I can suggest:

/system scheduler
add comment="" disabled=yes interval=1s name=schedule1 on-event=\
    "/system scheduler disable schedule1 ;\r\
    \n/system reboot;" policy=\
    reboot,read,write,policy,test,password,sniff,sensitive start-date=\
    jan/01/1970 start-time=00:00:00

This schedule will reboot the router and disable itself. You just have to enable it to reboot

/system scheduler enable schedule1

use

/system reboot;

Important : write ;

Hi,

I found the good way to force reboot !!!

If you can login via telnet, and you are getting an error when rebooting, you can do this :

  • Enable WatchDog and assign to it any ip.
  • After a minute the routerboard will reboot.
  • But you have to disable the watchdog timer immediately after reboot.

Regards,

This command could use an improvement. I suggest:

/system reboot confirmation=no
#!/usr/bin/perl

use strict;
use Net::Telnet; 

my $host = "192.168.88.1";
my $login = "admin";
my $passwd = "";

my $t = new Net::Telnet (Timeout => 30, Prompt => '/\] > $/' );
        $t->open( $host );
        $t->login( $login, $passwd );
        $t->cmd('
/system reboot;
y');
        $t->close();

exit

I think, the best way to force reboot (until there is no support for confirmation=no switch) is to create one-time scheduler, which starts 10s after creation and calls /system reboot command (no confirmation required then):

/system scheduler add name=reboot on-event="/system reboot" start-time=([/system clock get time] + 00:00:10)

Tested on v6.34.2.

/system scheduler add name=REBOOT interval=5s on-event=“/system scheduler remove REBOOT;/system reboot”

try with :execute {/system reboot;}

Hi guys.

if you need to do this via telnet…

try writing this script as two commands in notepad and then paste them both into the terminal window:


/system reboot
y

I do agree with the original poster that having a confirmation=yes or require_confirmation=no would be useful.
Clearly workarounds have been offered but they do not solve the underlying problem or question.

Also most unix / Linux systems allow this and if you are managing the router via ssh (do people still use telnet?) if you’re sending such a command you clearly want to do just that.
For interactive use it’s fine to ask for confirmation and that makes sense so confirmation probably should be required by default but given Mikrotik’s cli interface has quite a flexible input format I would imagine adding such a feature would be straight-forward and resolve this.

It would be nice to see such a change.