skip to Main Content

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.

3

Answers


  1. 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
    
    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
  3. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search