我有一个简单的shell脚本,在终端中打开时运行正常但不会作为cron作业运行!
脚本如下:
#!/bin/sh
/usr/bin/sshfs example.com: /mnt
/usr/bin/rsync -az -v --progress -h --delete /mnt/html/ /home/user/html/
/bin/fusermount -u /mnt
为什么这不起作用的任何原因? 我是Ubuntu和Cron的新手,所以它可能很简单。
谢谢! (我通过cron GUI添加了作业,“计划任务”)
答案 0 :(得分:0)
您可以直接使用rsync
ssh,不使用fuse / mount。
rsync -az -v --progress -h --delete example.com:/mnt/html/ /home/user/html/
但无论如何,我认为你的情况下的问题是使用ssh键。
当ssh从cron
开始时,您必须检查使用了哪些键。并配置ssh,它将使用正确的密钥。
答案 1 :(得分:0)
尝试设置此
#!/bin/sh
. /home/<user>/.profile
crontab是独立的,您可能需要某些个人资料详细信息。