Skip to content

Get PID of process inside a SSH Connection #69

@xKushGene

Description

@xKushGene

While following code on the following command will work:

Normal use (exec):
sh file.sh

file.sh:
nohup dotnet file.dll > output.log 2>&1 & echo $! > save_pid.txt

The same code within a SSH::run(..) will semi-work:
\SSH::run([ 'cd www/laravel/storage/app/files/' . \Auth::user()->id . '/' . $fileID, 'nohup dotnet ' . $file->filename . ' > output.log 2>&1 & echo $! > save_pid.txt', ]);

Here the output.log will be created fine with the output. But the save_pid.txt with the pid of the created process will not be created.

So my first idea was to catch the pid of the created SSH Connection.
And if i want to close the process later i just kill the process of the SSH Connection.

But i couldn't found a function to catch the pid from the SSH Connection

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions