我编写了一个脚本,以便在 crontab 上重新启动时自动运行
这是我的配置crontab -e
@reboot /home/deploy/startup_script >> /home/deploy/startup_script.log 2>$1
这将启动脚本并创建登录/home/deploy
那么这是startup_script
#!/bin/bash
echo "Changing directory"
cd /home/deploy/source/myapp
echo $PWD
echo "Pulling Dev Branch..."
git pull origin dev_branch
echo "Running Bundle Install"
sudo gem install bundler
bundle install
echo "Deploying to Staging..."
bundle exec cap staging deploy
当我使用它手动运行此脚本./startup_script
时,它会正常运行,但是当我在 crontab 中自动运行它时,bundle command not found
即使我已经安装了捆绑器,它也能正常运行。
这是来自的日志startup_script.log
Changing directory
/home/deploy/source/myapp
Pulling Dev Branch...
From ssh://1.xx.xx.xx.io:20194/xx/myapp
* branch dev_branch -> FETCH_HEAD
Already up-to-date.
Running Bundle Install
Successfully installed bundler-2.0.2
Parsing documentation for bundler-2.0.2
Done installing documentation for bundler after 5 seconds
1 gem installed
/home/deploy/startup_script: line 12: bundle: command not found
Deploying to Staging...
/home/deploy/startup_script: line 15: bundle: command not found