I have this python script(discord.py):
elif message.content.startswith('/mz stop'):
for line in os.popen("ps ax | grep /MYSCRIPT | grep -v grep"):
fields = line.split()
pid = fields[0]
os.system('kill -9 '+pid)
elif message.content.startswith('/mz start'):
bashCommand = "nohup bash start.sh"
process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE)
output, error = process.communicate()
If I use /mz start in discord before /mz stop, "/mz stop" doesn't works. But If the command "/mz stop" before, it works and kill the process.
After /mz start i got this: nohup: ignoring input and redirecting stderr to stdout
and python stdout is killed(I can't use print()
)