V
V
Vladimir Korshunov2021-02-09 18:10:04
linux
Vladimir Korshunov, 2021-02-09 18:10:04

How to end a process running before connecting to the server?

I use a server on ubuntu for my telegram bot. I start it with nohup: nohup python3 bot.py & and usually end it with killall python3 . But now it works when there is only one bot, but when there are several of them, this approach is clearly not suitable. If I have not exited the terminal yet, then I can simply write ps, find out the pid of the process and kill it. But if I disconnect and then reconnect, then ps no longer displays this process, although it exists. How to find out his pid? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry, 2021-02-09
@GashhLab

I agree with Fox Jovovich 's answer , but I also advise you to study the ps command
in particular, try the following options
ps a
ps axu
ps axuf | grep python3

A
Armenian Radio, 2021-02-09
@gbg

man systemd. Create services for all your bots and manage them via systemctl

D
Dim Boy, 2021-02-09
@twix007

screen can be used

S
Saboteur, 2021-02-10
@saboteur_kiev

nohup python3 bot.py &
echo $!

will give the PID of the python3 process. You can throw it into a file with some kind of comment to know when to nail which one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question