What's new

Powering off the router by shell command

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

slytho

Regular Contributor
Hi!

I need to power off my router at a certain time of the day. I'd use a cron job for that, but what command can I use to shut down the router? Usually I'd use "shutdown" or "poweroff", but none of these are available. I have Entware installed. Is there a package that provides shutdown commands?

Best regards
 
Hi!

I need to power off my router at a certain time of the day. I'd use a cron job for that, but what command can I use to shut down the router? Usually I'd use "shutdown" or "poweroff", but none of these are available. I have Entware installed. Is there a package that provides shutdown commands?

Best regards
I think you can use "halt" but I don't know if it's wise to do this sorry.:oops:
 
The use of the halt command was discussed in this thread. You never said what router or firmware you have but unless the newer routers are different there is no ability to power off the router. All the halt command does is kill the running processes so that the router is in an idle state.
 
The use of the halt command was discussed in this thread. You never said what router or firmware you have but unless the newer routers are different there is no ability to power off the router. All the halt command does is kill the running processes so that the router is in an idle state.
Thanks for that @ColinTaylor :oops:
 
You never said what router or firmware you have

Sorry, I totally forgot to mention it: it's an AC87U on firmware 384.13-2.

there is no ability to power off the router. All the halt command does is kill the running processes so that the router is in an idle state

Oh, that's sufficient for me. A hardware timer clock takes care of switching off the power, but before that happens I want to shut down the router. Bringing it in an idle state is all I need. Thank you!
 
but before that happens I want to shut down the router.
Not sure I see much point in it, but shouldn't harm anything either. :)
 
A router is designed to be Hard Rebooted (i.e. physically pulling the power plug). What is special about your configuration that needs it to be idle first though?

I think a simple hardware timer will be healthier for the router in the long run. :)
 
A router is designed to be Hard Rebooted (i.e. physically pulling the power plug).
Indeed, but none of us have just a router. What we have is a router/WiFi access point/switch which is running services. Namely, Samba, NFS, Media server, Download Master, etc., etc. Plus all those unofficial add-ons. So our "routers" are more like servers nowadays.

Anything that writes to USB storage stands a chance of corrupting that device or the files on it if the power is unexpectedly removed. It's exactly the same issue you have with yanking a USB flash drive out of your PC without unmounting it first.
 
@ColinTaylor, I agree with all your points. :)

But in the last decade I have never seen any issue with pulling the power plug on a router, and with amtm's disk checking routine along with Ext4 with journalling enabled (amtm + swap file highly recommended even if not using any of its builtin scripts) even the USB I consider fairly robust too (certainly more so than on a PC).

Pull the plug, wait at least two minutes and simply apply power again and the router simply works (and usually works better too, after the 'Hard Reboot'). :)
 
I'm not sure if it matters with modern kernels, but back in the early days, I used to run "sync;sync;halt" to make sure any pending writes were done before halting and powering down. Reason for the double "sync"? Don't know. Probably superstition or urban legend.
 
Last edited:
@L&LD I must admit that I have a similarly cavalier attitude to my router, but that's because its USB drive doesn't contain anything that can't be easily recreated. On the other hand, I don't think you can compare a router from 10 years ago with the way people are using Merlin's firmware today.

Even though I rarely "jank" the power out of my router I have experienced USB corruption (coincidentally, only today I found another corrupted file from last year). I think this corruption happened when I was still using ext2, having since changed to ext4.

So my point is that telling people it's perfectly OK to remove the power from their routers as a blanket statement is wrong. Just because ext4 is good at recovering from such situations isn't a reason to rely on it. Not everyone uses ext4, many use NTFS for example. Telling them after they've lost their data that they should have been using ext4 will be of little comfort. Similarly, just because amtm's disk check can usually fix corrupted filesystems isn't a reason to believe that's an acceptable way of operating, especially as it cannot repair the individual files.

Granted the risk may be minimal for a single occurrence, but if you're doing this on a daily basis you're multiplying that risk. But my approach would still be "don't put anything on the router's USB drive that you're not prepared to loose".

YMMV
 
@ColinTaylor, as usual, you hit the nail on the head (mine). Ouch! :)

I don't have anything on a USB drive that I depend on. I've seen them lose data going across an office from one computer to another (less than 20'). Anything on my USB drive that lives on my router is easily recreated (well, except for past stats that are not that important to me).

And routers from 10 years ago are a far cry with how they can be used today!

I guess that not having a 'Shut Down' button in the GUI has made me see today's routers as mere appliances that are mostly bullet-proof? Thanks for giving the other side of that false belief.

Maybe we can get that button in the near future? :)

Along with the already available 'Safely remove USB drive' button and possibly a new 'Shut down all services' button (for the op in this thread), we should be able to cover all foreseeable scenarios?

In the real world though, there have been many times when there was no other option but to pull the power (Hard Reboot, as I call it). And even when setting up a router/network for longterm stability, rebooting (via the GUI) countless times had no effect on stability, but Hard Rebooting once and keeping the power off for at least 10 minutes made the network 'just work' again.

Please continue correcting me and I promise to keep learning as much as possible! :)
 
@ColinTaylor, I agree with all your points. :)

But in the last decade I have never seen any issue with pulling the power plug on a router, and with amtm's disk checking routine along with Ext4 with journalling enabled (amtm + swap file highly recommended even if not using any of its builtin scripts) even the USB I consider fairly robust too (certainly more so than on a PC).

Pull the plug, wait at least two minutes and simply apply power again and the router simply works (and usually works better too, after the 'Hard Reboot'). :)
Aside from a few shorted asus power cords I concur with your statement.
 
I'm not sure if it matters with modern kernels, but back in the early days, I used to run "sync;sync;halt" to make sure any pending writes were done before halting and powering down. Reason for the double "sync"? Don't know. Probably superstition or urban legend.
Yes, all us old Unix guys did the sync, sync, halt thing. :) Why? Just to make doubly sure I suppose.:D

I guess that not having a 'Shut Down' button in the GUI has made me see today's routers as mere appliances that are mostly bullet-proof?

Maybe we can get that button in the near future?
I've often thought such a button would be nice. Although in reality would we ever use it? As you say, it's inevitable that there will be times when the router will be powered off. In my case it's usually when I'm crawling around under a desk rearranging the power sockets. Am I really going to stop, fire up a PC, log into the router, hit the Shut Down button and then return to desk-diving?

I can see why Asus wouldn't add such a button to the GUI (in addition to the "remove USB" buttons). Such a button would only confuse the average customer, especially as in its "shut down" state the router would still be powered on. Cue more support calls...
 
Why? Just to make doubly sure I suppose.

Some early UNIX system returned earlier than expected from the sync command, so running it multiple times ensured on these systems that all buffers were truly flushed.
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top