經過大量研究,我找不到解決方案,但發佈了這個問題。SCP不在crontab中工作,但在命令行上工作
我有一臺電腦A和B都是Ubuntu桌面。我想將文件從A複製到B.我遵循的步驟。
1. ssh-keygen in computer A
2. Left password blank
3. Copied id_rsa.pub to computer B ~/.ssh/ from computer A
4. Renamed id_rsa.pub to authorized_keys in computer B
5. In computer A I did scp -i ~/.ssh/id_rsa -r /var/www/abc [email protected]:/home/abc/
如果我在命令行中執行第4步,它的工作正常。但是當我在crontab中做同樣的事情時
22 10 * * * root scp -i ~/.ssh/id_rsa -r /var/www/abc [email protected]:/home/abc
它什麼都不做。
到這裏看看:https://askubuntu.com/questions/23009/reasons-why-crontab-does-not-work – ceving