2

I want to run a Fortran program on a server. I am able to log into that server using the command:

ssh -X username@I.P. address

I used mkdir directoryname command to create a directory.

Then I compile the Fortran source code using

gfortran code.f90 -o code1

and run it with the command:

./code1

This should start to compile the program. How do I know whether the process has started, is continuing and or has finished?

Please also tell me what does the commands top, bg and kill PID number mean.

closed as too broad by Jesse_b, Archemar, Jeff Schaller, Romeo Ninov, G-Man Feb 27 '18 at 2:16

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 7
    Please try to ask only one question at a time. – Stig Hemmer Feb 26 '18 at 9:49
12

If your shell prompt doesn't reappear after running ./code1, then your program is running. When your shell prompt comes back, your program has exited.

top is like the Task Manger on Windows or the Activity Monitor on macOS. It's a program that lets a user view and manipulate processes.

If you want to start your program in the background so that you have access to your shell when it's executing, run the program as ./code1 &. Or, press Ctrl+z while the program is running to pause it and enter bg to resume it in the background.

You can kill (terminate) a program if you know its PID. The kill command actually sends signals to programs so you can do other things with it besides using it to tell programs to exit.

You can view a list of the processes currently running under your user account with ps -u $USER.

  • A background task may be signalled with its job ID. The job IDs are listed with the jobs command. To kill job number 1, use kill %1. – Kusalananda Feb 26 '18 at 6:38
  • dear @dsstorefile Thanks for the help. When the program runs in the background, how'll I know when it's finished? – mithusengupta123 Feb 26 '18 at 6:38
  • 2
    @mithusengupta123 There will be a message in the terminal saying Done. This only appears after you press Enter though (as to not interfere with whatever you may be doing). – Kusalananda Feb 26 '18 at 6:40
  • @Kusalananda When resumed in the background, is there a command which can tell me that the program is still running? – mithusengupta123 Feb 26 '18 at 6:43
  • 2
    @mithusengupta123 Yes, jobs. It will also be listed along with all other processes in top. – Kusalananda Feb 26 '18 at 6:44
1

When running the program, use ./code1 &, instead of ./code1. Note the &. That signals that the given process must be run asynchronously. Henceforth, you can check on the progress of the program by running ps. If you want to cast back into the program, run fg.

Also, please make another question when another is desired.

Not the answer you're looking for? Browse other questions tagged or ask your own question.