我想创建一个脚本来运行在crontab中,但是当我尝试在crontab守护进程下使用它时,我遇到了命令位置的问题。找到:git:通过crontab中的脚本没有这样的文件或目录
已经做了一些脚本的测试,似乎工作正常。
这里是:
# I add this cd because of crontab location
cd ~/Documents/gitrepobackup/
find . -type d -depth 1 -exec git --git-dir={} --work-tree=$PWD/{} fetch origin \; >> git_backup_update.log 2>&1
而且这是我收到的该日志的输出:
find: git: No such file or directory
这也是我在crontab中添加条目:
* * * * * ~/Documents/gitrepobackup/git_backup_update.sh
有人吗?
调整你的'PATH'。 'cron'的流行实现允许在_crontab_:'PATH =/bin:/ usr/bin:...'中设置环境变量。或者,将绝对路径传递给'git',例如'/ usr/bin/git' –
谢谢Ruslan,那是一条路,我做了'哪个git'并发现了位置,然后将它添加到脚本中。 – SipriusPT