Did you know that you can use the ubuntu CLI app called screen to run a long running script on your server without worrying about cancelling it due to an SSH disconnect?

# To create a new screen
$ screen -S heavyESdataimport

# Run the command
$ php artisan app:import-heavy-data-to-elasticsearch --parallel

# You can now close tehe screen and come back in a few hours
# To reattach to the session, you can use:
$ screen -r heavyESdataimport

One very important thing to note however:

Please do not use 'screen' as a manager for long running processes such as PHP or Nodejs scripts. Use PHP-FPM, PM2 or some other service.

I've seen this being done in production for a fairly large startup and 🤢

continue reading on twitter.com

⚠️ This post links to an external website. ⚠️