我有一个非常简单的bash脚本,它应该启动我的幽灵博客。我使用crontab
到启动时启动脚本,这里是我运行的crontab命令:Ghost博客的Bash脚本无法在服务器重启时启动
@reboot /var/www/ghost/launch.sh
脚本有以下代码:
#!/bin/sh
ps auxw | grep apache2 | grep -v grep > /dev/null
if [ $? != 0 ]
then
NODE_ENV=production forever start --sourceDir /var/www/ghost index.js
fi
当我sudo reboot
服务器,并使用forever list
找到进程在运行,我看到以下内容:
data: [0] sHyo /usr/bin/nodejs index.js 1299 1314 /home/webadmin/.forever/sHyo.log 0:0:1:25.957
当我nano
到该日志文件,日志说个E采用:
^[[31m
ERROR:^[[39m ^[[31mCould not locate a configuration file.^[[39m
^[[37m/home/webadmin^[[39m
^[[32mPlease check your deployment for config.js or config.example.js.^[[39m
Error: Could not locate a configuration file.
at checkTemplate (/var/www/ghost/core/config-loader.js:16:36)
at Object.cb [as oncomplete] (fs.js:168:19)
error: Forever detected script was killed by signal: null
这似乎是在寻找/home/webadmin/
,可是鬼魂是安装在/var/www/ghost
????
当我在服务器启动ssh
-ing后,在终端上手动运行完全相同的脚本时,该脚本正常工作。我运行:cd /var/www/ghost/
,然后./launch.sh
和幽灵博客出现,工作正常。日志对于forever
过程说以下内容:
^[[32mGhost is running...^[[39m
Your blog is now available on http://blog.example.com ^[[90m
Ctrl+C to shut down^[[39m
有什么不对我的脚本或crontab中,它不能正常启动脚本?
非常感谢 – Neil