Make programming a bit easier in Linux

Restarting services or killing them are the must repeated activities that I have to do during current project. Running maven commands and deleting ‘.svn‘ folders are so easy but those take time too. By the other hand all of them should accomplish in the operating system shell. Sometimes more than ten times per a day I have ran this commands. Moreover, everyone knew that it could be much easier to develop simple Linux bash scripts or define Aliases which contains more usage commands. Then, I developed below scripts and define some aliases to make it easier.

killj.sh is a bash script which kills my Java processes that consists ‘javaagent‘ keyword. The application needs javaagent‘ as VM parameter; so, I am looking for it to kill the right process.

#!/bin/bash
for i in `psef | grep javaagent | cut -c10-14`
do
/bin/kill $i
echo ” $i has killed.”
done
if [ $(ps ax | grep -c javaagent) -gt 1 ] ; then
echo “NOTE: There are more alive java process yet!!!”
else
echo “DONE”
fi


rmsvn.sh removes .svn folders recursively.

#!/bin/bash
echo
echo “Warning!!!”
echo “CHECK BELOW PATH. This will remove all .svn folders recursively!!!”
pwd
read -p “Are you sure (yes/no)? “
[ “$REPLY” == “yes” ] && rm –rf `find . -type d -name .svn` && echo “all .svn folders have been removed!!!”

Also I added below lines at the end of .bashrc file:

alias lt=’ls -alt | head -20′
alias ld=”ls –al -d * | egrep ‘^d'”
alias c=”mvn clean”
alias ci=”mvnPdevDskipTests clean install”
alias i=”mvnPdevDskipTests install”
alias jkill=”/bin/killj.sh”
alias rmsvn=”/bin/rmsvn.sh”
alias go=”cd /home/amir/projects/company/jcb2″
alias dpiproxy=”sudo cp -f /etc/tor/torrc.dpi /etc/tor/torrc
alias noproxy=”sudo cp -f /etc/tor/torrc.noproxy /etc/tor/torrc
alias tor=”sudo /etc/init.d/tor restart”
Now, compiling, cleaning and killing processes are much easier…

This entry was posted in Linux. Bookmark the permalink.

Leave a Reply