尝试在路径中执行带空格的cron脚本时出错


0

我有一个脚本,里面有几个rsync命令。脚本文件放在NTFS分区中,其所有者和组权限设置为root。

使用以下命令从终端手动运行文件没有问题:

"/mnt/Files/Software/Software Customizations/Linux/Scripts/rsync_backup.sh"

crontab条目是(我的crontab,而不是root):

0 15 * * 6 export DISPLAY=:0 && gnome-terminal -e "/mnt/Files/Software/Software Customizations/Linux/Scripts/rsync_backup.sh"

但是执行文件时出现以下错误

There was an error creating a child process for this terminal.
Failed to execute child process "/mnt/Files/Software/Software" (Permission denied)

截图:

Screenshot error

你能告诉我问题是什么吗? 看起来不像权限问题因为我可以在不使用sudo的情况下执行文件,并且路径只是部分截图,让我相信它是空格的问题。

Answers:


2

尝试逃离路径中的空间:

0 15 * * 6 export DISPLAY=:0 && gnome-terminal -e "/mnt/Files/Software/Software\ Customizations/Linux/Scripts/rsync_backup.sh"

那很有效,谢谢。我之前有空间逃脱但我把双引号删除了。我知道你需要它才能工作
Vortex
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.