What are alternative methods to running shell commands in PHP without causing timeouts?

When running shell commands in PHP, long-running processes can cause timeouts, especially when dealing with large amounts of data. One way to avoid this issue is to use alternative methods such as executing commands asynchronously or using background processes. This allows the PHP script to continue running while the shell command is executed separately.

// Example of running a shell command asynchronously using exec
$command = 'your_long_running_command_here > /dev/null 2>&1 &';
exec($command);