![使用 crontab 更改目录时出错](https://linux22.com/image/72364/%E4%BD%BF%E7%94%A8%20crontab%20%E6%9B%B4%E6%94%B9%E7%9B%AE%E5%BD%95%E6%97%B6%E5%87%BA%E9%94%99.png)
这是我的脚本,我正在尝试重命名文件夹中的文件。
rename1.sh
----------
#!/bin/bash
cd /home/lanein1/WestonIN7pm/"$(date +%Y-%m-%d)" && rename s/WestonIN/WestonIN7pm/ *.jpg
cd /home/lanein1/WestonOUT7pm/"$(date +%Y-%m-%d)" && rename s/WestonOUT/WestonOUT7pm/ *.jpg
这是我得到的错误:
can't cd to /home/lanein1/scripts/rename1.sh
我不明白为什么会出现此错误
克朗条目:
29 12 * * * cd /home/lanein1/scripts/rename1.sh >> /home/lanein1/scripts/rename2.log 2>&1
答案1
您要求将目录更改为脚本:
cd /home/lanein1/scripts/rename1.sh >> /home/lanein1/scripts/rename2.log 2>&1
也许你想运行它:
/home/lanein1/scripts/rename1.sh >> /home/lanein1/scripts/rename2.log 2>&1