-   Linux - Networking (
-   -   Put internet connection to sleep if no user activity (

bubuntu 10-12-2012 06:09 AM

Put internet connection to sleep if no user activity
I use satellite for my internet connection and have a fairly restrictive bandwidth (upload/download limit). I would like to put the internet connection (either network or router) to sleep if there has been to activity on the keyboard or mouse for some period.

I've made a through search but haven't been able to find anything. I hope someone can help.

If this isn't the proper forum I apologize and please put it where it should be. I did read the sticky about what is and isn't a networking question.


tronayne 10-12-2012 01:43 PM

You know, if you're using HughesNet (or, for that matter, WildBlue) not a lot of traffic goes from your system(s) to the satellite when you're not doing anything. Given that you're using Ubuntu, you might want to shut off the automatic updates downloads (or set the update time to the middle of the night when your use is not limited or throttled if you can do that). Pretty much the only thing that runs periodically is NTP syncing with external time servers but that's not too often, really quick and there's little traffic involved. Now, this assumes that you don't have a fixed IP address and that you're not running a web service (with standard HugheNet the outside world can't get to you). Basically just shut down your browser and you aren't doing much of anything.

If you're really worried about it, you might want to shut down inetd, your internet service daemon, or simply pull the power plug on the satellite modem (that'll definitely shut down the satellite). Neither of those are particularly attractive (you'd have to restart inetd or wait a while for the modem to sync up with the satellite at power on).

You are aware that you don't get charged when the provider downloads their own updates to you or when they're just checking to see if your modem is alive; you do get charged for your own upload and download activity, but, if you schedule those in the middle of the night, you don't get charged.

I don't know of any way to automagically disconnect; I suppose it could be done but, sorry, no clue how. I'd just do it the easy way and unplug the thing or pull the network connector.

Hope this helps some.

JaseP 10-12-2012 01:52 PM

Jupiter might help. It's a package that allows for finer control over power management.

jefro 10-12-2012 08:14 PM

There is always a lot of traffic on them that you may be charged for so one could do many tasks to help prevent this.

One is to simply turn off the computer. Another is to use some acpi power setting to put entire system to sleep.

As above any sort of tc or bandwitch control along with even a specialized vm of some firewall, bandwidth. One can configure it all in to most distro's if they want.

It may be possible to configure only the nic to sleep with acpi and some other circumstances but it is not common.

tronayne 10-13-2012 09:43 AM

A lot of this depends upon what you're actually doing -- if you're downloading distribution ISO files during the day, well, you're going to pop over your daily limit which only means that you get throttled down to dial up speeds. I have HughesNet, I'm connected 24/7 and I monitor what's coming in and going out. I don't have a problem with getting throttled if I schedule big downloads at 0230 or so (when you don't get throttled -- they've got this fair use policy that permits that). I live in northeastern Michigan at just shy of 45 degrees north on U.S. highway 23 (kind of a main drag) off Lake Huron (big lake). We're pretty sparsely populated (neighbors are a hundred yards or so apart). There is fiber optic cable going in in rural areas (being paid for with stimulus money) that may or may not come to where I am (it's all around us but not in our particular stretch of highway -- yet). In this area cell phone service is iffy; we're in a hilly, heavily forested area not particularly conducive to RF -- you can see the dang towers north and south but zip cell service; it's telephone wires, satellite or nuthin.

Hughes did put up a new satellite recently that's coming on line now offering much higher upload and download speeds -- roughly equivalent to copper wire DSL service. As I understand it many ISPs are throttling, hard to get "unlimited" service in many places.

What it gets down to is that normal day-to-day use is fine but downloading massive files requires a little twiddling to not go over the fair use limit. You don't get charged extra but you do get throttled down to dial up speeds. It's better than nothing, a lot better than dial-up, and all you've got to do is be a little cautious with moving multiple gigabytes around. It's the price you pay for living in a really nice place.

bubuntu 10-14-2012 06:17 AM

Thanks all for suggestions.:hattip: I have wildblue and just switched to the new high speed satellite. Whats happening is that something - one of the webpages open in chrome or chrome itself is constantly sending data which adds up to a few hundred Megs in a day. I haven't had time to resolve exactly what although firefox doesn't seem to do it. I'll eventually resolve what is causing this and take appropriate steps.

tronayne - "you might want to shut off the automatic updates downloads" I do have those turned off, have ever since MS started that automatic "we know best" nonsince and continued doing so with Ubuntu. "you might want to shut down inetd, your internet service daemon, or simply pull the power plug on the satellite modem". What I'm doing now is just disconnecting from the network. It's only a couple of clicks off and a couple back on but I have to remember to do it - my senior moments are getting more frequent and lasting longer. I was just hoping there was something easy and automatic. "I monitor what's coming in and going out" How are you doing that? I'm using vnstat which is good for one computer but I have three. I haven't been able to get the router (Linksys with dd-wrt) to tell me amounts for the whole network. I'm on a mountain in north Alabama with only 2 other houses 3 hundred yards away so if I ever get any cable or DSL it will be a very LOOOOOONG time. If i stand on the corner of the deck and lean out a bit when the moon is waxing and there's no wind I can get maybe two bars on my cell. As you so aptly state, it's "the price you pay for living in a really nice place"

JaseP - I will take a look at Jupiter.

jefro - will try to see if there is a way to "configure only the nic to sleep with acpi"

I've been using Ubuntu for about four years and love it. I spent my career designing computer controlled systems. Digging into the guts of various hardware interfaces, writing drivers and such. I could probably figure this out and write some code to do it, but now I'm retired and just want a computer to more or less be an appliance so I can go fishing more.

Thanks again for all the replies. I'll look into your suggestions but I hope you understand if I just take the lazy way out.

tronayne 10-14-2012 09:45 AM

I've found that sticking out my tongue and crossing the toes on my right foot can sometimes improve signal strength... just a thought.


GKRellM can be useful for monitoring single or multiple systems; from the manual page:

With a single process, gkrellm manages multiple stacked monitors and supports
applying themes to match the monitors appearance to your window manager, Gtk, or
any other theme:

SMP CPU, Disk, Proc, and active net interface monitors with LEDs.

Internet monitor that displays current and charts historical port hits.

Memory and swap space usage meters and a system uptime monitor.

File system meters show capacity/free space and can mount/umount.

A mbox/maildir/MH/POP3/IMAP mail monitor which can launch a mail reader or
remote mail fetch program.

Clock/calendar and hostname display.

Laptop Battery monitor.

CPU/motherboard temperature/fan/voltages display with warnings and alarms.
Linux requires a sensor configured sysfs, lm_sensors modules or a running mbmon
daemon. FreeBSD can also read the mbmon daemon. Windows requires MBM.

Disk temperatures if there's a running hddtemp daemon.

Multiple monitors managed by a single process to reduce system load.

A timer button that can execute PPP or ISDN logon/logoff scripts.

Charts are autoscaling with configurable grid line resolution, or

can be set to a fixed scale mode.

Separate colors for "in" and "out" data. The in color is used for CPU user
time, disk read, forks, and net receive data. The out color is used for CPU
sys time, disk write, load, and net transmit data.

Commands can be configured to run when monitor labels are clicked.

Data can be collected from a gkrellmd server running on a remote machine.

gkrellm is plugin capable so special interest monitors can be created.

Many themes are available.
It's actually kind of neat (and you may already have it on your system).

There's also ntop which does for network activity what top does for system activity:

ntop shows the current network usage. It displays a list of hosts that are cur-
rently using the network and reports information concerning the (IP and non-IP)
traffic generated and received by each host. ntop may operate as a front-end col-
lector (sFlow and/or netFlow plugins) or as a stand-alone collector/display pro-
gram. A web browser is needed to access the information captured by the ntop pro-

ntop is a hybrid layer 2 / layer 3 network monitor, that is by default it uses the
layer 2 Media Access Control (MAC) addresses AND the layer 3 tcp/ip addresses.
ntop is capable of associating the two, so that ip and non-ip traffic (e.g. arp,
rarp) are combined for a complete picture of network activity.
That you most likely will not have, but it's certainly worth a look-see.

I don't know much about Chrome, haven't been tempted, but I'd think that if you see network activity when Chrome is just sitting there and that stops when you shut it down... eh? Does it start as a daemon? And, does that daemon die or sit there running after you shut down Chrome?

I know that Firefox periodically checks for updates (usually just when it starts but every so often I do notice network activity lasting a few seconds that I attribute (possibly incorrectly) to Firefox doing its thing). And, of course, if a mail application is running there's going to be periodic activity when it checks for new mail.

I'd be tempted to get ntop so you can see what's what and perhaps GKRellM too just for a simple visual display you can keep an eye on. What the heck, might help, won't hurt.

Hope this helps some.

jefro 10-14-2012 01:45 PM

Get all the good things that help prevent data. Simply blocking images in browsers was my old dial up way. Script blockers and good firewalls and hosts files may help.

If you can live with them, try a more basic browser or a text browser.

See wireshare for what you are sending out. Many simple web pages have hundreds of links that are not worth showing so block them.

It might be worth it to remove dns and use hosts file to both block and allow only the sites you want to visit. Most people only visit 50 or so sites so that is all they really need to let their computer access.

bubuntu 10-14-2012 06:29 PM

I do have GKRellM and it is interesting, mostly use it to monitor temps but the little graphs are cool. I'll study it some maybe it can do more than I thought.

I tried ntop a while back but never quite got it working correctly. I'll look at that again also. For now though the weather's great and I'll be mostly fishing. I guess if I'm not home on the internet my data usage should drop - like a roof not leaking when it doesn't rain. Hmmm maybe this is a good solution.

I'll report in when I have some results.

bubuntu 10-20-2012 09:24 PM

The last time I said I would report back on an issue I waited till I had worked through the whole thing and it was like writing a final report on a project at work. So in the interest of being lazy and retired I'm going to do this piecemeal. I'm following through with this mostly in case some one else can benefit. I've gotten some very good help from this and other forums and would like to contribute where I can. :hattip:

I installed Jupiter but the only thing I saw which related to my original question was just being able to turn connection on/off. Maybe I missed something but so far doesn't look like a solution.

Stay tuned.

bubuntu 01-18-2013 09:11 PM

I have a solution. Not quite what I had hoped for but it works. I found this blog: Run scripts when gnome-screensaver starts or stops in Ubuntu. If I set up the scripts as described it works fine.

Here is the script ssTriger copied from the referenced web site with a small change (used "call" instead of "Popen" to invoke the scripts to run at start and stop of screen saver activation):


#!/usr/bin/env python
from gobject import MainLoop
from dbus import SessionBus
from dbus.mainloop.glib import DBusGMainLoop
from subprocess import Popen
from subprocess import call

class SSTrigger:
    def __init__(self):
    def catch(self,ssOn):
        if ssOn == 1: #Screensaver turned on
            call(["sudo", "/opt/ssTrigger/ssStart"])
#            call(["sudo", "ifconfig","eth0","down"]) #works if ifconfig set in sudoers
        else: #Screensaver turned off
#            call(["sudo", "ifconfig", "eth0", "up"]) #works if ifconfig set in sudoers
            call(["sudo", "/opt/ssTrigger/ssStop"])


ssStart is:

echo "start"
#sudo ifconfig eth0 down
ifconfig eth0 down

ssStop is:

echo "stop"
#sudo ifconfig eth0 up
ifconfig eth0 up

Both ssStart and ssStop are owned by root. These and ssTriger (owned by me) are in /opt/ssTrigger as per the referenced web page I got all this from.

Also have added this to /etc/sudoers so I don't have to enter my password when the scripts run.

user_me ALL=(ALL) NOPASSWD: /opt/ssTrigger/ssS*
I'm running ssTrigger from a terminal window and it works flawlessly. Need to test having it start automatically at login.

I see some draw backs:
1) Unless I put the scripts in /home/whatever I'll have to remember to copy it and sudoers back in if I make a clean install of Ubuntu. The security conscarn'tious folks say scripts which have sudo privileges with out needing a password shouldn't be in user space.
2) I'll have to resolve the problem if I change screen savers.
3) I don't know if this will work with another desktop such as Cinnamon.
These aren't serious so I'm satisfied for now and am going to mark this thread solved.

Thanks again to all for your help.:D

bubuntu 01-21-2013 12:04 PM

:cry:Well I spoke to soon. It was working perfectly last I had the computer on and today it doesn't. The only thing I can see different so far is that last time when screen saver actvated it gradually dimmed the display to dark and today it just suddenly goes dark.:confused:

Computers have been doing this kind of stuff to me for almost 50 years and sometimes it's hard not to take it personally. I've offended the computer gods again. :smiley for ARGGGG! (if I could find one):

All times are GMT -5. The time now is 07:52 PM.