T
T
TANK_IST2017-09-12 22:59:50
linux
TANK_IST, 2017-09-12 22:59:50

How to stop a command running in the background using an ampersand?

The server has continuous integration. And when pushing to git, CI executes commands.
One of them is php bin/console sockets:start &.
&I use it to run in the background.
And on a new push to git, this command is run a second time.
How to stop the previous one so that only the last one works in the background?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Saboteur, 2017-09-13
@TANK_IST

Kill the previous process with kill
It is prudent to create a .pid file with the process number in your php immediately after startup, so that you can track whether the process is running on it.
In general, this is the task of any configuration engineer junior

C
CityCat4, 2017-09-13
@CityCat4

You can use fg to call a background task on the terminal.
You can shoot with kill if pid is remembered somewhere

S
sim3x, 2017-09-12
@sim3x

tldp.org/LDP/abs/html/x9644.html
The fg command switches a job running in the background into the foreground. The bg command restarts a suspended job, and runs it in the background. If no job number is specified, then the fg or bg command acts upon the currently running job.
or
ps-aux | grep php
kill -15 process number
kill -9 process number

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question