Disable a few cores when you want to save power.

If you have a lot of CPU power and working on battery. If you do not need that much of power and would like to rather save some battery power by disabling some cpus then you can use the below script. This script disables cpus from 4 to 7. You can change the number in the for loop. You would need the sudo to be setup or remove sudo and run the script as root. The script will show you the currently active cpu’s before and after disabling the CPU’s.

If you want to disable to cpus from the grub itself then you can add the below parameter in grub.cfg or grub2.cfg in the vmlinuz line:

1
maxcpus=4

Here is the script:

#!/bin/bash -
#===============================================================================
#
#          FILE: disablecpu.sh
#
#         USAGE: ./disablecpu.sh
#
#   DESCRIPTION:
#
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Amit Agarwal (aka)
#      REVISION:  ---
#===============================================================================

#set -o nounset                              # Treat unset variables as an error
cat /proc/cpuinfo|grep cores|wc -l
for i in {4..7}
do
    sudo sh -c "echo 0 > /sys/devices/system/cpu/cpu$i/online"
done
cat /proc/cpuinfo|grep cores|wc -l
Enhanced by Zemanta

Battery performance improvement with powertop and using xidel.

For those of you, who have not heard about powertop, it is a tool to monitor the power consumption on your system. It has a tab which shows the tuneable parameters. Doing the changes suggested in those would improve the life to quite an extent. Here is the description of powertop:

PowerTOP is a tool that finds the software component(s) that makeyour computer use more power than necessary while it is idle.

So, here is something that you can do to quickly apply the changes suggested by tuneable parameters.
First, get the report in html format using

sudo powertop --html

With this you will get powertop.html and now quickly get the xidel binary from sourceforge site. Once you have got that exeute the command

xidel powertop.html   -e "css('html body div#tuning table tr td:nth-child(2)')"

This will show you all the tuneable parameters of your system 🙂

 

Enhanced by Zemanta

quick bash script for datewise backup of directory

I was working on something and the data was very critical and needed backup. I wrote a bash script to back up the data every 5 hours with cron and bash script. Thought I will share that with you. Here is the script.

#!/bin/bash - 
#===============================================================================
#
#          FILE:  backup.sh
# 
#         USAGE:  ./backup.sh 
# 
#   DESCRIPTION:  Backup all the current files.
# 
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR: Amit Agarwal (aka), [email protected]
#       COMPANY: Roamware India Pvt Ltd
#       CREATED: 08/19/2011 02:43:32 PM IST
#      REVISION:  ---
#===============================================================================
backupf=( a b c d) #Here you need to specify the directory you need to backup.
bkupdir="/tmp/backup/$(date +%Y)/$(date +%m)/$(date +%d)" #Here you can change the basedir for the backups
mkdir  -p $bkupdir
sudo tar cvfz $bkupdir/bkup_$(date "+%Y%m%d_%H%M").tgz $backupf[*] #Remove sudo if you do not need it.
echo "Backup created in dir $dir"

And then just add it to cron as “00 */5 * * * /home//bin/backup.sh”. Change the path if it does not match what is given here.

Enhanced by Zemanta