Jun Aruga's Blog

Output, activities, memo and etc.

Travis CI: A better alternative of travis_wait to output the command stdout

I found a better way to run heavy command, seeing a code [1] by chance.

If the command does not output log to stdout or stderr for 10 minutes, the job stops. The popular practice to prevent it is like this. But the problem is this command does not output while processing the command.


  - travis_wait 40 heavy_command 

And below is a better way.

  # Ping stdout every 9 minutes or Travis kills build,
  # while travis_wait does not show the command output while processing.
  # https://docs.travis-ci.com/user/common-build-problems/#build-times-out-because-no-output-was-received
  - |
    while sleep 9m; do
      echo "====[ $SECONDS seconds still running ]===="
    done &
  - heavy_command 

$SECONDS shows the processing running time. It seems that is reserved environment variable by Travis CI.