crontab:“未找到 ftp 命令"macOS中的错误

编程入门 行业动态 更新时间:2024-10-25 14:29:49
本文介绍了crontab:“未找到 ftp 命令"macOS中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这里是新手.我一直在寻找解决方案,但似乎找不到.

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中的错误

本文发布于:2023-11-17 04:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608836.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:未找到   命令   错误   macOS   crontab

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!