这里是新手.我一直在寻找解决方案,但似乎找不到.
Newb here. I've been looking for solutions about this but I can't seem to find one.
来自我的 crontab 的错误日志:
/Users/harrold/bin/ftp_automate.sh: line 14: ftp: command not found我制作了一个名为 ftp_automate.sh 的脚本,将文件从我的本地文件夹发送到我的 ftp 服务器.该脚本使用 % sh ftp_automate.sh 在终端(zsh) 中运行.这是脚本:
I have made a script named ftp_automate.sh sending files to my ftp server from my local folder. The script works in terminal(zsh) with % sh ftp_automate.sh. Here's the script:
#!/bin/bash # FTP server details here SERVER="ftp.DUMMYSITE" USERNAME="DUMMYUSER" PASSWORD="DUMMYPASS" # local directory containing source backup file SOURCEFILES="/Users/harrold/Desktop/FOLDER/ftp-test" # remote server directory path in which backup needs to be put in BACKUPDIRCTORY="/folder/subfolder" # login to remote server ftp -n -i $SERVER <<EOF user $USERNAME $PASSWORD cd $BACKUPDIRCTORY bin lcd $SOURCEFILES mput * quit EOF但是,我希望它使用 crontab 来工作,所以它每分钟都能完成这项工作.这就是我使用 % crontab -e 的方式:
However, I want it to work using crontab so it does the job every minute. This is how I did it with % crontab -e:
* * * * * /Users/harrold/bin/ftp_automate.sh >> /Users/harrold/bin/logs/ftp.log 2>&1知道为什么我收到 ftp command not found 错误吗?
顺便说一句,我的脚本放在/Users/harrold/bin中.
By the way, my script is placed inside /Users/harrold/bin.
推荐答案我明白了!
我只需要在我的脚本中添加 ftp 的完整路径,如下所示:
I just had to add the full path of ftp on my script, as in:
/usr/local/bin/ftp -n -i $SERVER <<EOF此外,我必须在我的 bash 配置文件中添加 ftp $PATH vi .bash_profile 在我的主目录(例如/Users/harrold)
And additionally, I had to add ftp $PATH on my bash profile vi .bash_profile on my home directory (e.g. /Users/harrold)
export PATH="/usr/local/bin/ftp:$PATH"为了使更改生效,我必须使用 source ~/.bash_profile
For the changes to take effect, I had to reload my profile with source ~/.bash_profile
更多推荐
crontab:“未找到 ftp 命令"macOS中的错误
发布评论