Archive for category linux
More than 100% CPU in top in Linux/Mac
If you are power linux/mac user you should have noticed at least once that top shows more than 100% CPU for a process. I also have seen this multiple times but always wondered how it can be. Here is an example of how my top looked when I started my java and was doing some number crunching.
Recently I did a bit of research and got to the bottom of this. So here is the reason for it. A process is said to be using 100% CPU if it uses a processor to the limit that processor goes ie it completely uses that CPU without giving any idle/free time for that CPU. Now consider the situation that we have a multi core CPU. What if the process has more than one thread ? Well if so there is a chance that the threads can be split between two cores. So if 100% is one CPU running at maximum power, then what is one CPU at maximum power and other using 10% of its computing power? Its 100% + 10% = 110%. That’s how the magical more than 100% CPU value comes in.
Continue reading “More than 100% CPU in top in Linux/Mac” »
Auto Backup using Dropbox in Linux/Mac
Posted by Srijith R in linux, shell scripting on November 9, 2011
I had some folders on my disk which I wanted to keep a copy online as a backup and for viewing from other places. Its not always possible to save all the essentials in the drop box folder itself to be auto backed up. Thus I wrote a very small script which does this for me. All it does is read all the folders which needs to be backed up from the text file “dropboxFolders.txt” and copy them to dropbox folder. The rest is done by dropbox scripts. Hence I expect the dropbox program to be running always in the background. So here is the script:
#!/bin/sh foldersInfo="dropboxFolders.txt" dropboxFolder="/home/<user>/Dropbox/" while read line do from=`echo "$line" | cut -d":" -f1` to=`echo "$line" | cut -d":" -f2` echo $from" to "$to mkdir -p "$dropboxFolder$to" cp -R "$from" "$dropboxFolder$to" done <$foldersInfo
The file dropboxFolders.txt should be in the format
/home/<user>/WorkingCode:WorkingCode
Continue reading “Auto Backup using Dropbox in Linux/Mac” »
User Level Threads
Posted by Srijith R in Assginment, C, linux on October 9, 2011
User level threads is created for light weight threads. It needs to be controlled, context switched and swapped by the process. To the Operating System it is only one process without any threads. Here is one implementation of it:
Continue reading “User Level Threads” »
Service Engineer/System Administrator Interview Questions
Posted by Srijith R in interview, linux, shell scripting on October 1, 2011
This is not my code alone. It was the group effort of Vivek Ram, Cijo George, Sandeep Unni and mine during our epic preparation for Yahoo!. I am just putting it open for others who would be looking for this information. Continue reading “Service Engineer/System Administrator Interview Questions” »
Automatic Command Archive
Posted by Srijith R in linux, shell scripting on August 17, 2010
The default command storing size of ubuntu is 500 commands. It stores the commands in home folder in the file “.bash_history” .
The problem is 500 commands is too short of a size.
One method is to increase the command size to a large value by changing the $HISTFILESIZE variable using the following command
Continue reading “Automatic Command Archive” »
How to Save file in vi not opened with sudo
Posted by Srijith R in linux, shell scripting, vi on August 17, 2010
It has happened to me a lot of times that i edit a file in vi. I insert and edit a lot and finally when I try to save it I find that I dont have permission for it. If only I had opened it with sudo. I found a solution for this issue. It was actually a simple command and here it is
Continue reading “How to Save file in vi not opened with sudo” »
Auto Away Notifier for Pidgin in Perl
Whenever I am away from laptop my chat buddies leave me lots message and finally lots of “You there???”. So I thought of making a script that would inform my buddies that I am away when someone sends me a message.
This method works with Pigin API.
I have used /proc/acpi/button/lid/C267/state file to find if the lib of the laptop is closed or not. This file may vary in your laptop. So try to find the find the file in your computer that stores the status of the lid. It should be a file in /proc/acpi/button/lid/ folder and replace the file accordingly in your computer.
The Content of /proc/acpi/button/lid/C267/state is state: open and state: closed when the lid was closed.
Continue reading “Auto Away Notifier for Pidgin in Perl” »
BSNL Dataone Auto Downloader
Posted by Srijith R in acpi, dataone, linux, shell scripting on August 16, 2010
Bsnl(India) provides an account that has 2am to 8am unlimited download. It was not easy to wake up at 2am and switch on the computer and sleep again. So I tried to find a method to switch on the computer automatically at 2am and download and shutdown at 8am. Although the I thought the idea was foolish, I found out that there actually is a method for doing it. “ACPI Alarm” was introduced in 1999 or so (Even my old PC had it).
Continue reading “BSNL Dataone Auto Downloader” »
Recent Comments