linux – 如何找出后台进程的进程ID?

我有一个命令(程序),我想用nohup和后台运行它.喜欢

nohup command > logfile.txt &

我如何找出进程ID?我希望能够在文件中编写进程ID,稍后读取并以编程方式终止进程.

解决方法

在你的脚本中:

nohup command > logfile.txt &
echo $! > /var/run/command.pid

相关文章

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注