Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exit from bash script but keep the process running

Tags:

linux

bash

shell

I'm running a server and needs to execute following command with the parameters. The scripts works great at the moment but the problem is when I run the script I cannot return back to the console. It keeps running in the console. If I stop it forcefully then the the process also going to stop.

I want to keep running the process and return to the console.

#!/bin/sh
php /home/stjc/app/artisan queue:listen --timeout=60 --tries=5

Thanks

like image 737
Achintha Samindika Avatar asked Mar 12 '23 20:03

Achintha Samindika


1 Answers

Run that process in background:

#!/bin/sh
(php /home/stjc/app/artisan queue:listen --timeout=60 --tries=5) &

try adding an ampersand(&) at the end with brackets on either side of original command.

Edit:

: is a shell builtin which means NOP depending on your OS it might a problem try escaping the it in the php command and see if it works for you

#!/bin/sh
(php /home/stjc/app/artisan queue\:listen --timeout=60 --tries=5) &

also puting the full path to your php interpreter is strongly advised.

like image 158
anand Avatar answered Mar 19 '23 03:03

anand