this is my script "backup.sh":
#!/bin/bash
date=$(date +"%m-%d-%Y_%r")
mmv -r "uploads/temp/*" "#1\ '$date'"
mv /ftphome/uploads/temp/* /ftphome/uploads/arch/
My dir structure is like that:
dr-xr-xr-x 9 it2 it2 4096 Feb 29 12:09 arch
drwxrwxr-x 2 it2 it2 4096 Feb 29 12:09 temp
When I try to execute script from console all is working - as root, because otherwise I get an error "directory uploads/temp/ directory not allow writes" <- I set this permission on purpose.
Unfortunately when I'm try to start this script by corn, mmv command doesn't execute, and all files move to "arch" directory without suffix.
I was trying to change chmod permission to 777 for "temp" dir, but it doesn't help. I edited crontab as root, so it should work as root (that info I read in this topic: How to run a cron job using the sudo command ).
BTW, it is like i try to execute script by cron (every minute is for testing):
* * * * * /ftphome/backup.sh
uploads/temp/
for the source directory. You may need to use full paths for the commands as well e.g./usr/bin/mmv
. Also,'$date'
will likely not be expanded because of the single quotes. – steeldriver Feb 29 '16 at 14:24