exec cp failes from script, yet works when issued directly
3
votes
1
answer
187
views
I have a script that copies SQL backups to a windows server. Here's the line from /etc/fstab:
//my.win.box/share$ /winshare cifs credentials=/etc/credfile,dom=mydomain,uid=0,gid=0,file_mode=0600,dir_mode=0700 0 0
Here's the backup script:
backup.sh:
# copy zipped sql exports to /winshare/db
find /backups/sql/*sql.gz -mtime +1 -exec cp {} /winshare/db \;
Logged in with root privileges (in this case, as root)
$ ./backup.sh
cp: cannot create regular file `/winshare/db/mydb_20130301.sql.gz': Permission denied
Yet if I issue the command from a prompt, rather than through the script:
$ find /backups/sql/*sql.gz -mtime +1 -exec cp {} /winshare/db \;
The file(s) are copied as expected. Again, logged in as root here.
What could be causing the in-script command to fail, yet the identical command to work from console?
Asked by a coder
(3343 rep)
Apr 23, 2013, 07:55 PM
Last activity: Mar 14, 2025, 03:38 PM
Last activity: Mar 14, 2025, 03:38 PM