gitwithravish's avatar

Laravel command process id

I run a single command using multiple workers and save the command related details (output, status, execution time etc.) into the database. I also want to save a unique ID (such as process id) that distinguish each worker execution.

Any idea how can I get this information in my laravel Command ?

0 likes
2 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

You can use the getmypid() function to get the process ID of the current worker. You can then save this ID along with the other details in the database.

Here's an example of how you can use it in your Laravel command:

public function handle()
{
    $pid = getmypid();
    // save $pid along with other details in the database
}

Hope this helps!

1 like

Please or to participate in this conversation.