cron not liking ?backticks, ?pipes ?head exp
I am running this script via an .sh file within cron:
/bin/sh /path/to/cp -rp "`var=$(ls -dt -- /folder-one/folder-two/*/ | head -n1); var="${var%??}"; echo "$var"`" "/folder-three/folder-four/" the script is designed to copy the latest folder from the conents of /folder-one/folder-two/* anyone can help? thanks compused |
I would use only the $( ... ) notation for command substitution and not the backticks. It makes it much easier to read.
But the actual problem is probably coming from the quotes. You have double quotes inside your double quotes and the inner sets need to be escaped. |
Usually you put everything in the script, and then just put the name of the script in the cron job. But make sure you use full paths, because cron uses a different environment than the command line in a virtual terminal.
|
yes, it is overcomplicated. It is not the cron who does not like it, but the human beeing who cannot construct such a complex command in one single line.
As it was suggested better to put it all in a script and you invoke only the script from cron. Furthermore I would try to simplify it: Code:
# for example, instead of |
thanks a lot guys...those suggestions seem to have fixed it...
|
glad to help you.
If you think your problem is solved please mark the thread solved. If you want to say thanks just click on yes. |
All times are GMT -5. The time now is 01:48 PM. |