Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script failing to mv a file when the file exists???

Status
Not open for further replies.

Chrissirhc

Programmer
May 20, 2000
926
GB
I've got a crontab that runs a script and in the script is a line to rename a directory. Something like mv /app/myapp/logs/AppLog.log /app/myapp/logs/AppLog<date>.log

Anyway my crontab is emailing me

mv: cannot rename /app/myapp/logs/AppLog.log: No such file or directory

When there blatently is a file there... If I type &quot;cp /app/myapp/logs/AppLog.log /app/myapp/logs/test.log&quot; That works.

I can't do much testing because this is in a controlled environment. So I'm looking to you guys for ideas...

Maybe my script has some hidden characters that I'm not aware of???

Thanks in advance,

Chris
 
Is the /app/myapp/logs/AppLog<date>.log
exactly how it appears in your script? If so, replace the <date> with `date` (note backticks, not apostrophes) and it should work. If that's not the case, post back. HTH.
 
Thanks a lot Ken.

The problem was to do with the file I was trying to rename to not the file I was trying to rename from.. As you had thought.

Although I didn't have <date> in it. that was just an example to say that the date was included somehow :) Bad example I guess.

Anyway problem solved.

Thanks,

Chris

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top