You can use maxuploadtarget by adding a line like:
maxuploadtarget=5000
to the bitcoin.conf file in your .bitcoin directory. The example above will set a daily soft upload limit of ~5GB/day.
Even better might be limiting the maxconnections with
maxconnections=25
Below is a Perl script I have written that will run on Linux, and will automatically limit the maximum number of connections (and thus bandwidth) during the day, and then once nighttime rolls around, it will remove the connection/bandwidth restrictions. This way, while you are asleep, your Bitcoin full node can be making the most of your bandwidth, and when you're awake, the full node won't interfere with your web browsing during the day.
#!/usr/bin/perl
use warnings;
use strict;
#############################################################################################################
#Program purpose: To configure a Bitcoin full node so bandwidth use is restricted during the day.
#
#How it works: The bitcoin.conf file is periodically modified so that Bitcoin runs with fewer connections
#during the day (using less bandwidth), and unlimited connections (higher bandwidth) at night.
#
#How to run: On Linux, run within the Bitcoin /bin directory (i.e. the directory holding 'bitcoind').
#############################################################################################################
#Set the path of Bitcoin's bitcoin.conf file here:
my $path_of_bitcoin_conf_file = $ENV{"HOME"} . "/.bitcoin/bitcoin.conf";
my $bitcoind_connection_max = 25; # The maximum number of connections for bitcoind to make during day hours.
my $start_of_day_hour = 7; # 7 am.
my $start_of_night_hour = 21; # 9 pm in 24 hour format.
my $time_period_last = "hasn't been recorded yet"; #Records whether the last time check was "day" or "night".
#Run indefinitely, configuring node bandwidth restrictions based on time of day.
while (1) {
my $time_period_current = night_or_day();
#When the day becomes night or night becomes day, configure bitcoin bandwidth accordingly.
if ( $time_period_last ne $time_period_current ) {
modify_bitcoin_conf_file($time_period_current);
restart_bitcoind();
}
else{} #Night/day hasn't changed, check again in another minute.
$time_period_last = $time_period_current;
sleep 60;
}
#Modify bitcoin.conf to limit bandwidth during the day, but unlimited during the night.
sub modify_bitcoin_conf_file {
my $night_or_day = shift;
my $last_line_of_bitcoin_conf_file;
if ($night_or_day eq "night"){
$last_line_of_bitcoin_conf_file = ""; #No maxconnections limit at night.
}
elsif ($night_or_day eq "day"){
$last_line_of_bitcoin_conf_file = "maxconnections=$bitcoind_connection_max\n";
}
else{die "Error, no night or day\n";}
#Check that bitcoin.conf exists and then open it for editing.
if (-e $path_of_bitcoin_conf_file){
open (my $bitcoin_conf_fh, "<", $path_of_bitcoin_conf_file);
my @bitcoin_conf = <$bitcoin_conf_fh>;
close $bitcoin_conf_fh;
open ($bitcoin_conf_fh, ">", $path_of_bitcoin_conf_file);
foreach my $line (@bitcoin_conf){
print $bitcoin_conf_fh $line unless $line =~ m/maxconnections/;
}
print $bitcoin_conf_fh $last_line_of_bitcoin_conf_file;
close $bitcoin_conf_fh;
print "The bitcoin.conf file has been changed to $night_or_day settings ", scalar localtime, "\n";
}
else {
die "Could not locate the bitcoin.conf file: '$path_of_bitcoin_conf_file'\n";
}
}
sub restart_bitcoind {
shut_down_bitcoin_if_running();
start_bitcoind();
}
sub shut_down_bitcoin_if_running {
#Check if Bitcoin is running.
if ( bitcoind_is_running() ){
print "Bitcoin daemon is running, trying to shut down now. ", scalar localtime, "\n";
shut_down_bitcoind();
}
else{
print "Bitcoin daemon is not running at the moment. ", scalar localtime, "\n";
}
}
sub shut_down_bitcoind {
if ( program_running("./bitcoin-cli stop", "Bitcoin server stopping") ){
sleep 10;
#Verify bitcoind process has stopped.
while ( bitcoind_is_running() ) {
print "Still waiting for Bitcoin daemon to shut down. ", scalar localtime, "\n";
sleep 10;
}
print "Bitcoin daemon successfully shut down. ", scalar localtime, "\n";
}
else{
print "Having problems shutting down Bitcoin daemon. ", scalar localtime, "\n";
}
}
sub bitcoind_is_running {
if ( program_running("ps -e", "bitcoind") ){
return 1;
}
else{
return 0;
}
}
sub start_bitcoind {
unless ( system("./bitcoind -daemon") ){
print "Bitcoin server booting up. ", scalar localtime, "\n";
sleep 30;
#Verify Bitcoin server has fully booted.
until ( bitcoin_server_is_up() ) {
print "Still waiting for Bitcoin server to fully load. ", scalar localtime, "\n";
sleep 60;
}
print "Bitcoin server has successfully loaded. ", scalar localtime, "\n";
}
else{
print "Having problems starting the Bitcoin daemon. ", scalar localtime, "\n";
}
}
sub bitcoin_server_is_up {
#If we can get a block count, then the server is booted.
if ( program_running("./bitcoin-cli getblockcount", '^\d{6,}') ){
return 1;
}
else{
return 0;
}
}
#Call a program with argument 1, and return true if its stdout matches argument 2.
sub program_running {
my ($shell_cmd, $stdout_match) = @_;
open (my $prog_call, "-|", $shell_cmd);
while (my $stdout = <$prog_call>){
if ($stdout =~ m/$stdout_match/){
return 1;
}
else{} #Keep searching for match.
}
return 0; #Match not found.
}
#Determine if it's nighttime or daytime.
sub night_or_day {
my @current_time = localtime();
my $current_hour = $current_time[2];
if ($current_hour >= $start_of_day_hour && $current_hour < $start_of_night_hour){
return "day";
}
else {
return "night";
}
}