Run a job in the background on Linux instance

When we are working on a remote Linux instance, there are a lot of times that we need to run some intensive computation Job/Process on the instance, which are time-consuming. The Job/Process can be run for more than an hour or even a day, and the struggle connecting can ruin the whole process. I had that issue a few years ago that I need to run some experiments for more than a day and I always stuck with the message “Write Failed: broken pipe” by unstable connection. Therefore, in this post, I want to share a solution to that issue. On the one hand, you can increase the timeout of ssh to avoid the connection lost issue. However, that is not a good solution to the problem, power or the Internet outage can still ruin your process. There is a special command for this task.

On the Linux system, there is a command called “nohup“, which allows Job/Process to able to run in the background (even we are logged off). The usage of this command is very simple. We just need to run “nohup” with our regular command. 

$nohup ./testRunning "argv1" "argv2" ... &

Note that the last symbol (&) is required. This will set the system to run the process even we are logged off. However, we might want to keep the output (stdout and stderr) from the process. We can also save the result to output file by the following command

$nohup ./testRunning "argv1" "argv2" ... > out.txt 2>&1 &

The command will redirect the output from both stdout and stderr to a filename “out.txt”. The first “>” symbol pipeline stdout to filename out.txt and the second symbol “2>&1” append stderr (“2”) to stdout (“1”).

With nohup command, you don’t need to keep worrying about the connection to the instant and you don’t need to keep your machine login to the instant ( Safe some energy ( ͡❛ ͜ʖ ͡❛) ).

What is a Ph.D. Study?

Recently, I just obtained my Ph.D., and I think it is a good time to write about this topic. What is a Ph.D. study? What exactly are we doing? Why it take so long? Many people who are not in the research field might think Ph.D. is one kind of degree which you need to take a lot of class/exam and after you complete all requirement you will obtain that degree. Someone might think if you are smart enough, you can just go for it as a straight line and you will get a degree in well defined years. Thought, it is incorrect. A Ph.D. study doesn’t have a solid definition like other degrees that have a solid plan or flow chart of the study.

So what is a Ph.D. study? If you are lazy to read the whole article, the short answer is “Ph.D. study just one kind of training to become a researcher or an educator”. Yes, it is just training to fulfill skills that you need to become a researcher or an educator. During the training, you will also have to study something that very narrow or wide area. In this process, everyone will face different training depending on what skill you are lacking. As we can see, it is hard to determine how long it will take to finish. For example, some skills can be developed in a short amount of time, however, some others could take many years of practice. In some fields of study, it could take less than 3 years, but in some other areas, it could take more than 7 years. Then at the end of the training, you will be awarded the highest academic degree or Ph.D. Therefore, the next question will be how to know that a candidate is ready to obtain the degree? 

The answer is a candidate need to invent some new knowledge and present it to the world. By that, every university/institute has different criteria to qualify candidates. Not only that but most of the time the laboratory, which insides university/institute, also has additional criteria. For example, in my case, my requirement to allow me to graduate from the university are obtaining course work graduate credits hours, passing a qualifying exam, presenting a major area research work to a committee, and defending a dissertation to a committee member. However, I also have an additional requirement from my laboratory that I need to publish three scientific papers in a well know conference/journal in my field. As we can see by this requirement, not only a researcher or educator is the outcome of the training process, but also a brand new research topic that can push the humanity to a new frontier of knowledge.

In conclusion, Ph.D. is a unique degree that doesn’t have a solid timeline or flow chart. It is actually just training to become a researcher or educator. In addition to that, you will also study to become a specialist in some area. The outcomes of a Ph.D. study is not the thesis/Dissertation, but it is the candidate who will become the next generation of researcher or educator.

I also have a final note for any readers who are pursuing the degree as a Ph.D. Candidate, I encourage you to keep pushing, beyond the frontier. I know that you may found a challenging or failure in this path, but please remember one thing. You are smart and you are working with the smartest group of people on the planet. If you can’t solve this problem who will?