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 ?
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
}