Sandy C Sandy C - 12 days ago 4
Bash Question

Calling multiple, independent shells in Heroku

I am looking for this kind of shell scripting equivalent in Heroku dynos.

start cmd /k call "batch1.bat"
start cmd /k call "batch2.bat"


I tried

. batch1.sh &
. batch2.sh &


Even this one crashed.

./batch1.sh &


Would like to know if Heroku supports this activity. If yes, kindly help me with the correct set of commands.

Answer

You can spin up a heroku one-off dyno, as follows:

heroku run bash

This gives you an interactive bash shell, from which you can invoke any script in your git repo.

You can also, of course, run "batch" scripts directly, e.g:

heroku run bash -c "ls -lt"

That will spin up a one-off dyno instance, whose bash shell will run whatever command was passed to it, in this case, "ls -lt". After completing the command, the one-off dyno shuts down.

Note that as with all Heroku dynos, the filesystem is ephemeral, so any files created by your script will be gone after your one-off dyno exits.