I'm trying to invert my eth0 status with a shortcut key <F11>.
code:
!#/bin/sh
if ((ip a show eth0 up)!=NULL); (ifconfig eth0 down); (ifconfig eth0 up)
pls correct my syntax.
Moderators: 666philb, Forum moderators
pls correct my syntax.
Re: pls correct my syntax.
Something like:
Code: Select all
#!/bin/sh
if ifconfig | grep -q ^eth0
then
ifconfig eth0 down
else
ifconfig eth0 up
fi
If you are using JWM window manager, you should probably use jwmdesk
to configure F11
to execute the script. (note: scripts have not been tested)
You really should determine what causes the slow down,
eg not enough ram, or fast transfer of data to/from an ntfs file system, which can load the cpu.
Different causes might require different solutions.
If you want to keep the network up, for example, to keep access to a network printer, it could probably be blocked blocked another way, for example, using the iptables firewall.
Starting Libreoffice'ss word processor like this might do what you want. Or not.
Code: Select all
ifconfig eth0 down
swriter
ifconfig eth0 up
A script like this could disable the network if the cpu load is more than 2.0
Code: Select all
#!/bin/sh
while true
do
uptime | awk '{exit $8>1.8}' && ifconfig etho down
sleep 60
done
This script does not automatically bring eth0 up again.
And it does not test whether eth0 is already down.
The awk command gets the pu load average for the last minute,
so there is no point in sleeping less than 60 seconds.
-
- Posts: 4321
- Joined: Fri Jul 24, 2020 10:59 pm
- Has thanked: 1875 times
- Been thanked: 581 times
Re: pls correct my syntax.
thanks william 2
that works fine.
nb
RAM now at 4GB, swapfile at 512MB. things much better, but freezes still happen. computer inadequate.
-
- Posts: 4321
- Joined: Fri Jul 24, 2020 10:59 pm
- Has thanked: 1875 times
- Been thanked: 581 times
Re: pls correct my syntax.
@boof I see your PC's post. This may not change things, as you may be having some hardware issue(s) causing your problem. BUT, I offer this info: It has always been recommended to use a SWAP partition/file that "mirrors" RAM...at a minimum. Thus, you might consider increasing your SWAP size to 4GB.
Since 3.5 decades ago, I use SWAP partitions on EVERY Unix/Linux setup ever done for several reasons from lab tests done back then. Modern operating systems benefit from these SWAP/PAGING layouts.
AND, I would NEVER put a SWAP on a USB stick!!! Thus your PCs system drive or on the fastest HDD/SSD/Raid drive you have connected to your platform would yield your best outcome.
If you find this helps, run with it.
Re: pls correct my syntax.
4 GB should be adequate for most programs.
You can check the cpu usage by running something like
mpstat 60 >/tmp/iostat.log
or iostat[ 60 >/tmp/iostat.log
the 60 is to print every 60 seconds.
If you want to see which processes are using the most cpu power, you can use top.
top -c -b -o +%CPU -n 10 >/tmp/top.log
or
top -c -b -o +%MEM -n 10 >/tmp/top.log
It can all be done using "ip" command
@Clarity Yes, ip is the newer one, ifconfig is depricated, but it still works.