I found a better way to run heavy command, seeing a code  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.
script: - travis_wait 40 heavy_command
And below is a better way.
script: # 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.