What does the linux make command do? - linux

I created a database and a table inside it.I insert records manually and then run a python script which reads the records and updates them in the table. I was just trying
the make &>1.txt command to redirect the output when the unexpected happened.
Even when I am not running the script and insert the record manually from mysql, the script is
running somewhere as it updates the records , but I am not running it any tab
What is the reason ??
The script just starts running by itself!!!

If it's running in the background (which could have happened if you typed make & >1.txt with a space, not what you showed above) then the jobs command will show it is running, and fg will bring it to the foregound, so you can kill it with Ctrl-C
(You can also kill it with the jobspec shown by jobs e.g. kill %1 but if you don't know what you're doing it's simpler to bring it to the foreground and interrupt it)

Related

How to Stop & Start Screen Jobs Using Scripts in Linux

I want to use some scripts to stop and start a bunch of programs, each running in a separate linux screen. These programs run continuously and need to be stopped using Ctrl-C.
So I can write some code to stop a screen:
screen -S "mysessionname" -X quit
but do I need to send a Ctrl-C somehow first of all and if so then how?
Also, I can start a new detached screen thus from within a script:
screen -mdS "mysesssionname"
but how can I then kick of the job from within this screen using a script? I've tried attaching to the session and then starting the job all from within a script but it doesn't seem to work
Well let's hope that this can help you but to simulate the Ctrl-C in a script as far as i know you can use something like kill -3 and the pid of the process. See in manual of signals: "man 7 signal"

After disown a process how can I again read the stdout of the running process

I have a c program which is running on linux. I applied some command for running the process in background after closing the terminal.
1. Pause program with `Ctrl-Z`,
2. Pull it into the background with `bg`
3. Then disown it.
Now i want to see the console output of this program which is still running.
How can I do it in linux?
If the terminal used to run the command has been closed and you are using a new one, I guess that the standard output of the background process was closed, so that you cannot do that.
A very simple way is to use screen.
Another way is to redirect output to a file when the command is run, and access the file later.

How to QLOGIN to a node that shared a specific job-id

I have an existing qlogin job like this:
job-ID prior name user state submit/start at queue
-------------------------------------------------------------------------
3530770 0.50500 QLOGIN jlsmith r 10/15/2012 14:02:07 mri.q#compute-0-29.local
The above job was submitted using standard qlogin command in linux:
$ qlogin
What I want to do is to perform another qlogin so that the process
are running in the same node with the above Job-ID 3530770.
The idea is that if it's done correctly in top command I can see the same running
process submitted to the above job-ID.
Is there a way to do it?
Either
qlogin -l h=compute-0-29.local
or
qlogin -q "*#compute-0-29.local"
Should do the job
Based on talking to some HPC specialists at work and some Google searching on the subject (I also wanted to resume a job ID), it's not really possible if you've already submitted the job. You can qlogin -q <node name> into the node again, but you cannot resume the job on the shell screen.
If you are thinking of starting a new qlogin job, but you would like to be able to resume it at some future point, then you can use screen to do this.
Before you write qlogin into the command line at the front-end node, write screen. It should completely clear the terminal screen.
Now qlogin and put in your job script interactively.
Once your job has started running and you want to leave for a bit, press and hold Cntl while you press A and D. It should say that your screen was detached and take you back to the front-end node. If you qstat now, you should see your job running.
When you want to resume the job ID (see the running process on the terminal screen), in the front-end node write screen -r. You should be able to see your running process in the terminal again.
Note: if you do this several times and you accumulate multiple screens by accident (happens to me every time), when you screen -r you will get multiple choices instead of automatically resuming the one you want. To try each one out, type screen -r <name of screen listed> one at a time until you find the one you want (detach as specified above). To get rid of the extra screens, write screen -D -r <name>.
Hope this helps.

Running a node.js process in background after giving inputs to it

I have this node.js server which, once spawned, expects some input from stdin. The inputs shouldn't be given straight away: I need to wait for some event before giving them (e.g. a connection from somebody). If I give the commands and close the shell, the server shuts itself down. I would like to give the input to the server and close my shell (effectively leaving the server running).
I know that to run a process in background I need to do for example node my_server.js &, but this prevents the input from the command line. I would like to give this input AND then put it in background. Modules like forever puts it in the background automatically without letting me giving the inputs through stdin.
Moreover putting the script in background kills anyways the server when closing the shell.
Any suggestion?
Thanks
I did a quick test just using gedit in Ubuntu 12.04, and it worked.
Start your node app like so "node app.js arg1 arg2" however you want to and hit enter to start the program. Then hit CTRL-z once your program has started running. This gives you the terminal back but stops the process in the background. To let it run in the background now, simply "bg" and hit enter. This will let the process keep running now but in the background.
You can confirm you are still up with the command "ps -ef | grep node" which should show your program still running.
However, this does still leave the node process attached to the terminal window so when you close the terminal window it will close the process. But I think this will get you most of what you seem to be looking for quick and easy.
You asked for any suggestion, so here it is: make your server able to start without user interaction. The simplest way to do it is probably to create a file containing exactly the input needed by the server, then starting it like this:
node my_server.js < my_input.txt &
If the input needed depends on what the server outputs (ouch), use expect(1). If possible, subvert the whole thing and use a module like commander to get your inputs from the command line instead of stdin.

bash background process not working, or am I missing something?

I have written a script to split my pdf files between pages I give, and compress them using gs and then output it to a pdf file.
I want to run my script in the background, but am I missing something? I should use & at the end of line, but it still prints output. so I use:
./gs 12 20 temp > /dev/null &
but it just goes to the background and I should use fg to run it actually.
so what is it I am missing? & should send the process to background but it stops at background. I want it to run in background.
edit:
problem is solved. it was my mistake to look for wrong file the script creates.
it works like a charm!
The output is from your shell. When you background a job, it prints the job id [1] and the process id 9324 so that you have a way to manipulate your background jobs. It indicates that the job is in fact running in the background.
To bring it back to the foreground, fg %1 (to refer to the job id, use a percent sign) or to kill it, kill 9324.

Resources