リモートサーバにsshログインしたあと、何か操作をするというシェルスクリプトを作ったのですが、ターミナルからは動くのに、crontabからはなぜか上手く実行されないという問題に遭遇しました。 原因は、expectスクリプトの最後が、 interact となっていたこと。 これを、 expect eof exit と直すことで無事動かすことが出来ました。 元のシェルスクリプト(端末で動作) #!/bin/sh host="user@host" pass="password" command="実行するコマンド" expect -c " set timeout 10 spawn ssh ${host} ${command} expect \"Are you sure you want to continue connecting (yes/no)?\" { send \"yes\n\" exp