8 – Executing a php script in the background through the admin portal

On my Drupal site, I have a few scripts that I currently execute manually using drush script .... Unfortunately, as it’s set up now, I have to ssh into my staging/production environments and run them.

I would like to create an interface in the admin portal that allows admins to trigger off these scripts, only, I would like them to execute in the background. I’d prefer to not have to convert these to cron jobs because 1] some scripts take hours and 2] they don’t need to be ran on a regular basis.

I’d simply like the admins to be able to kick off scripts in the background with the click of a button. If a script is running, it should disable the interface’s button when the page is loaded.

Could someone point me towards how I could achieve this?