Run background task in Google Colab

151 Views Asked by At

I writing some scripts in Google Colab. I am not using Google Colab pro - just the basic version.

Part of the flow requires me to execute a binary command (i.e. bash command) - to set something running in the background. The issue is this command never completes, and so I cannot execute any more cells below.

The flow I need in the Google Colab is:

  1. Run the binary (!PATH_TO_BINARY_IN_GOOGLE_DRIVE)
  2. After a set time (30 seconds) the bash command in 1. is moved to a background process (or put to sleep).
  3. The user of the google colab notebook can then proceed to run following cells

So far I have tried two things:

  1. !(PATH_TO_BINARY_IN_GOOGLE_DRIVE&; sleep 40). This does not work in google colab, throws a syntax error around ;.
  2. Write a small python script to run the binary and the sleep. The binary executes but does not sleep.

I am open to any solution that can get this working - i.e. allows me to run a binary in the background on Google Colab.

0

There are 0 best solutions below