Home > Blockchain >  Execute each line of bash in separate terminals
Execute each line of bash in separate terminals

Time:10-11

I have create a simple bash script for my laravel project (file name: bash-script.sh)

php artisan serv

php artisan queue:work --queue=first_queue

php artisan queue:work --queue=second_queue

php artisan queue:work --queue=third_queue

php artisan queue:work --queue=fourth_queue

php artisan schedule:work

the problem is I want each line of these commands to run in separate terminals.

CodePudding user response:

If you want them to run in a terminal window, you will have to start a terminal window.

xterm -e "php artisan serv"
xterm -e "php artisan queue:work --queue=first_queue"
xterm -e "php artisan queue:work --queue=second_queue"

# et cetera

CodePudding user response:

Or if you do not have a graphic environment on the host (ie you connect to the remote host via ssh) you need a terminal multiplexer like screen or tmux

For both, there are several howto and example all over the web

CodePudding user response:

Maybe this can help you, in the same terminal all processes responses:

php artisan serv &
php artisan queue:work --queue=first_queue &
php artisan queue:work --queue=second_queue &
php artisan queue:work --queue=third_queue &
php artisan queue:work --queue=fourth_queue &
php artisan schedule:work

The ampersand (&) it's for executing in another process and freeing the current execution, all outputs in every processes will write on the same terminal

  • Related