0

So I'm using a Putty session to run a script on background.

my script can be located by

cd /var/www/listingapp.

Then I will run the command

php /var/www/listingapp/public/index.php batch/GetPrefecture init > /dev/null &

so I'm expecting that the script will run in background, but after I close the putty CLI and try to re-open it, the process can no longer be found when entering the command

ps aux | grep /var/www/listingapp

So this means it stopped. How do I make it to run in background when session is terminated?

andil01
  • 377
  • 4
  • 19
  • Take a look at the `screen` utility (server side). It offers a wealth of options. – arkascha Oct 20 '17 at 06:42
  • tried that but the client demands a one-time command for users. – andil01 Oct 20 '17 at 06:48
  • @arkascha could I use something like, `screen php /var/www/listingapp/public/index.php batch/GetPrefecture init > /dev/null &` ? – andil01 Oct 20 '17 at 06:50
  • Did you try to put your question to google? The first hit: [How to keep processes running after ending ssh session?](https://askubuntu.com/q/8653/280048) - or [Keep SSH Sessions running after disconnection](https://unix.stackexchange.com/q/479/119732) - Btw, all this are rightly on different sites, as this is not a programming question. – Martin Prikryl Oct 20 '17 at 06:50
  • You can setup the `screen` utility once _before_ the user connects and then just "use" it in subsequent sessions. – arkascha Oct 20 '17 at 06:51
  • Possible duplicate of [How to run process as background and never die?](https://stackoverflow.com/q/4797050/850848) – Martin Prikryl Oct 20 '17 at 07:29

1 Answers1

1
nohup php /var/www/listingapp/public/index.php batch/GetPrefecture init &
andil01
  • 377
  • 4
  • 19