与kubectl exec运行后台进程
I am trying to execute a python program as a background process inside a container with kubectl as below (kubectl issued on local machine):
我试图在一个容器内执行一个python程序作为后台进程,如下所示kubectl(在本地机器上发布kubectl):
kubectl exec -it -- bash -c "cd some-dir && (python xxx.py --arg1 abc &)"
kubectl exec -it - bash -c“cd some-dir &&(python xxx.py --arg1 abc&)”
When I login to the container and check "ps -ef" I do not see this process running. Also there is no output from kubectl command itself.
当我登录容器并检查“ps -ef”时,我没有看到此进程正在运行。此外,kubectl命令本身没有输出。
Is the kubectl command issued correct?.
kubectl命令发出正确吗?
Is there a better way to achieve the same?
有没有更好的方法来实现同样的目标?
How can I see the output/logs printed of the background process being run?
如何查看正在运行的后台进程的输出/日志?
If I need to stop this background process after some duration, what is the best way to do this?
如果我需要在一段时间后停止此后台进程,那么最好的方法是什么?
Thanks
2 个解决方案
#1
0
Actually, the best way to make this kind of things is adding an entry point to your container and run execute the commands there. Like:
实际上,制作这类东西的最好方法是在容器中添加一个入口点并运行那里的命令。喜欢:
entrypoint.sh
:
#!/bin/bash
set -e
cd some-dir && (python xxx.py --arg1 abc &)
./somethingelse.sh
exec "$@"
You wouldn't need to go manually inside every single container and run the command.
您不需要在每个容器内手动运行并运行该命令。
更多相关文章
- Python脚本——连接到SSH并运行命令
- conda不是内部或者外部命令
- 在python中复制命令的正确方法[复制]
- 基础入门_Python-进线协程.分分钟玩转multiprocessing多进程编程
- python使用多进程爬取图片
- pip常用命令汇总
- pip常用命令、配置pip源
- Python随心记--进程、线程
- 我需要一个django-芹菜守护进程来监听特定的rabbitmq通道