當我運行fabric.py來部署我的站點時Ubuntu。Fabric執行時拒絕權限rm -rf
我遇到了錯誤:
[192.168.15.143] run: rm -rf /home/user/project/weather_station/
[192.168.15.143] out: rm: cannot remove '/home/user/project/weather_station/logs/gunicorn.log': Permission denied
[192.168.15.143] out:
Fatal error: run() received nonzero return code 1 while executing!
Requested: rm -rf /home/user/project/weather_station/
Executed: /bin/bash -l -c "rm -rf /home/user/project/weather_station/"
Aborting.
Disconnecting from 192.168.15.143... done.
我認爲這是錯誤是關於拒絕的權限。
我引用this
因此,我改變run('rm -rf {}'.format(PROJECT_DIR))
爲sudo('rm -rf {}'.format(PROJECT_DIR))
但仍error.Is有什麼辦法?
如果使用'operations.sudo()'而不是'operations.run()'會發生什麼? – fernandezcuesta
錯誤是完全相同的。我可以在fabfile中設置像'sudo -H rm -rf'這樣的參數嗎? – CJCheng