記一次shell指令碼的坑
阿新 • • 發佈:2018-12-30
先看下面這個指令碼:
#!/bin/bash PATH=/www/server/nvm/versions/node/v8.11.1/bin export PATH cd /cron/toy/ node index.js echo "----------------------------------------------------------------------------" endDate=`date +"%Y-%m-%d %H:%M:%S"` echo "★[$endDate] Successful" echo "----------------------------------------------------------------------------"
這個結果執行的時候報錯:
line 5: node: command not found
改成:
#!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/www/server/nvm/versions/node/v8.11.1/bin #PATH=/www/server/nvm/versions/node/v8.11.1/bin export PATH cd /cron/toy/ node index.js echo "----------------------------------------------------------------------------" endDate=`date +"%Y-%m-%d %H:%M:%S"` echo "★[$endDate] Successful" echo "----------------------------------------------------------------------------"
成功了!!!