If – Rudyar Kipling

If you can keep your head when all about you
Are losing theirs and blaming it on you;
If you can trust yourself when all men doubt you,
But make allowance for their doubting too:
If you can wait and not be tired by waiting,
Or, being lied about, don’t deal in lies,
Or being hated don’t give way to hating,
And yet don’t look too good, nor talk too wise;

If you can dream—and not make dreams your master;
If you can think—and not make thoughts your aim,
If you can meet with Triumph and Disaster
And treat those two impostors just the same:.
If you can bear to hear the truth you’ve spoken
Twisted by knaves to make a trap for fools,
Or watch the things you gave your life to, broken,
And stoop and build’em up with worn-out tools;

If you can make one heap of all your winnings
And risk it on one turn of pitch-and-toss,
And lose, and start again at your beginnings,
And never breathe a word about your loss:
If you can force your heart and nerve and sinew
To serve your turn long after they are gone,
And so hold on when there is nothing in you
Except the Will which says to them: “Hold on!”

If you can talk with crowds and keep your virtue,
Or walk with Kings—nor lose the common touch,
If neither foes nor loving friends can hurt you,
If all men count with you, but none too much:
If you can fill the unforgiving minute
With sixty seconds’ worth of distance run,
Yours is the Earth and everything that’s in it,
And—which is more—you’ll be a Man, my son!

Rudyard Kipling
Advertisements

What is the difference between the ‘>’ operator and ‘|’ operator in Linux?

Piping and redirection are two powerful tools in the Unix kit. | is the pipe operator. > is the redirect operator.

Piping connects the standard out of one program to the standard in of another. You can think of it as a literal pipe: There’s a stream of data from the leftmost command to the right.

For example:

$ foo | bar

This connects foo’s standard out to bar’s standard in. What foo outputs, bar receives. You can build pipelines:

$ foo | bar | baz

This connect’s foo to bar and bar to baz. For a real example, the following chains together four commands to print all of the processes that are running on your system with more than one instance:

$ ps ax | awk ‘{ print $5 }’ | sort | uniq -dc

There is a little shell work here to set things up, but pipes mostly rely on existing kernel functionality.

Redirects are about files, not just processes:

$ foo > file

The standard out from foo is stored in the file named “file” instead of displaying on the console. The shell implements this by opening the file, setting it as standard in, and then running the new process.

Summary: Piping chains together two or more processes by connecting the outputs of an antecedent process to the input of the immediately subsequent process. Redirection is a shell feature that saves a process’s output in a file or copies a file into a process’s input.

You use pipes with processes, redirects with a process and a file.

-By Robert Love on Quora

What are the best ways to deal with frustration?

Music. Sleep. Long walk all alone. A new trip to a place you love. Get yourself busy.

Music : have a good collection of inspiring and good music which you love and relevent to you. It always helps and brings you up from any depression. I had experuenced this many times.

Sleep : most of our thoughts will get refined once we sleep. Your mind will get reduced on load. Leave it free for sometime. You will know the change. But I feel very dificult to get sleep at times.

Long walk : You will see a lot of things around you. So lovely. Si bad. So awesome. It will give you lot of relaxation. And one more important thing is, you will get lot of time!

Get yourself busy: Ultimate. Will make you grow. Your other pains jn work wont be a matter at this time. It will give you a better feeling for sure. I will be at my office, working, when I feel bad.

HowTo Restart a Daemon/Program in Linux if it Crashes/Killed

Most of security critical applications/services are pron to attacks and the first try is to kill/remove the process/application. Here in this post, im writing about the method to prevent the first try, to kill the service.

One method, is to restart the application when it is killed. For making an service/process to run as a daemon, In Linux, we can add a launching script at /etc/init.d/ directory, so that it will be started at the bootup init.

Here is a simple hello world program to demonstrate it.


#include
int main() {
     while(1) { /* Continue forever as a daemon */
     printf("Hello world\n");
     sleep(1); /* Sleep for one minute */
    }
}

Now compile it into hello.out and create a startup script to add it to init.d as below.

raj@08:39:10:$ gcc hello.c -o hello.out

while ! /home/raj/hello.out   #This will wait for the program to exit successfully .
do
echo “restarting”                  # Else it will restart.
done

Add this script hello.sh /etc/init.d/ to start it at boot time. But now, we can test it without rebooting.

Provide execution permission to the script and run the script on one termnial.

raj@08:39:22:$ sudo chmod +x /home/raj/hello.sh
raj@08:39:32:$ ./hello.sh

Now you can see the program running and printing Hello world string once in one minute. Now open one more terminal and kill this process by finding its pid as below.

raj@08:40:07:$ pidof hello.out
26685
raj@08:40:20:$ sudo kill 26685.

Now, you can see the process being started again.
Here is screenshot to give an overview.

Screenshot from 2012-12-02 08:40:54

 

Surely there will be may better ways, would like to know and if i come to know, i will update this. 🙂