Some nice linux tutorials
Some very nice articles and tutorials on Linux, find here. Pretty nice collection.
Some very nice articles and tutorials on Linux, find here. Pretty nice collection.
First we will setup cgroup to limit cpu and memory usage, so here we go:
Add the configuration in /etc/cgconfig.conf
#------start cgconfig---------------- #new group group firefox { perm { task { #user your login id and group here, so that you can control this group uid = amitag; gid = amitag; } admin { # same as above, set to your login id and group. uid = amitag; gid = amitag; } } # set the limits for cpu.. by default there are 1024 shares of cpu with no other groups, # so share of 102 would be around 10% . cpu{ cpu.shares="102"; } # limit the cpus to be used to only 0-1 cpuset{ cpuset.cpus=0-1; cpuset.mems=0; } # limit the maximum memory to 700Mb. memory { memory.limit_in_bytes="700M"; memory.max_usage_in_bytes="0"; } } #------end cgconfig----------------
Continue reading
For running mpd with different use, you may find necessary to change the SELinux context of your music directory. For this, you would need to run the below command:
chcon -R -t mpd_user_data_t Music/
Continue reading
cgroups is a kernel feature and with userspace utilities, we can use the feature to control the cpu and memory for per process. So, lets first install the required tools.
sudo yum install libcgroup-tools
Now, we need to enable the service.
sudo systemctl enable cgconfig.service sudo systemctl enable cgred.service
cgconfig.service is to enable configuration for cgroups and
cgred.service is to enable configuration for cgroups for processes depending on the name.
Just in case you need it, you can get the journalctl entries from systemd in the web page.
First install :
yum install systemd-journal-gateway
Once you have done this you can get the journal entries with wget as well with
wget http://localhost:19531/entries
or if you prefer, you can browse with a browser at http://localhost:19531/. It has a nice little interface for browsing the entries, nothing too fancy but just sufficient.
Continue readingWhen you have a lot of files in some repository and you have added a couple of new, in CVS there is no command to add just the new ones to the repository, so here is a workaround for that.
cvs status 2>/dev/null | awk '{if ($1=="?")print "cvs add -kb " $2}'
Well, if you are adding text files then you might want to remove the “-kB” in the cvs command above.
Continue readingIf you are using Linux (Fedora/Ubuntu or anything else) then you do get a lot of tools and one of them is cron. Very very useful. Just write some script that can do the task for you, put it in cron and forget it. So, here is a home grown way to schedule mails.
First, copy this script below:
#!/bin/bash - #=============================================================================== # # FILE: sched_mail.sh # # USAGE: ./sched_mail.sh # # DESCRIPTION: # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Amit Agarwal (aka), # REVISION: --- #=============================================================================== mailfile="~/mail" if [[ $(wc -l $mailfile|awk '{print $1}' ) -ge 5 ]] then to=$(grep ^To: $mailfile|sed 's/To: //') echo "Good to send mail... to = $to" sendmail -t <$mailfile echo "once mail is send, delete the contents of file" echo "sed -i '4,$ d' $mailfile" fi
Now, create a file called mail in your home directory, with the following contents:
Continue reading