Page 1 of 1
Help with mv (move) command & crontab
Posted: Sun Aug 03, 2008 7:11 pm
by kwisher
Hello All,
I need some help from the guru's here for a very simple script and how to set it up as a cron job. The script just uses the mv command to move a
folder of files to another folder on a separate drive. What I have so far is:
Code: Select all
mv /media/disk-2/office-backup/*.* media/usb-bu/office-backup/
This returns the error:
Code: Select all
mv: target 'media/usb-bu/office-backup/' is not a directory: No such file or directory
What am I doing wrong? I looked up the mv command and thought I followed the proper syntax.
TIA
Re: Help with mv (move) command & crontab
Posted: Mon Aug 04, 2008 5:13 am
by miket
Hi !
kwisher wrote:Hello All,
I need some help from the guru's here for a very simple script and how to set it up as a cron job. The script just uses the mv command to move a
folder of files to another folder on a separate drive. What I have so far is:
Code: Select all
mv /media/disk-2/office-backup/*.* media/usb-bu/office-backup/
This returns the error:
Code: Select all
mv: target 'media/usb-bu/office-backup/' is not a directory: No such file or directory
What am I doing wrong? I looked up the mv command and thought I followed the proper syntax.
TIA
You've missed off the leading forward slash in the destination :
Code: Select all
mv /media/disk-2/office-backup/*.* /media/usb-bu/office-backup/
As for cron, it will depend how you want to run it, as user root or as your own user ?
Pop open a terminal and enter :
It will outline everything there is know !
Any questions just drop a note here and I'll try and answer them for you ...
Mike.
Re: Help with mv (move) command & crontab
Posted: Mon Aug 04, 2008 4:45 pm
by kwisher
AvanceIT wrote:
You've missed off the leading forward slash in the destination :
Code: Select all
mv /media/disk-2/office-backup/*.* /media/usb-bu/office-backup/
Your command line returns the following:
Code: Select all
mv: inter-device move failed: `/media/disk-2/office-backup/2008-08-03_15.48.32.201832.office.ful' to `/media/usb-bu/office-backup/2008-08-03_15.48.32.201832.office.ful'; unable to remove target: Is a directory
Re: Help with mv (move) command & crontab
Posted: Tue Aug 05, 2008 3:02 am
by Fred
kwisher,
Before I can really answer your question accurately, I need to know what you are trying to accomplish. Are you trying to move or copy? Are you working with a folder tree, multiple files, or a single file? The mv command has a lot of options.
If you are trying to sync a folder tree with multiple files in it to a usb stick, ie, keep a mirror backup, you might be better off using the rsync command. It only copies files that have changed and deletes files that have been deleted since the last backup, so it is very fast. It would work something like this:
Make a directory on the usb stick called say "office-backup" .
The rsync command would look like this:
sudo rsync -arE --progress --delete --timeout=120 --exclude "*~" --include "*" --include "*/**" /media/disk-2/office-backup/ /media/usb-bu/office-backup/office-backup
This command would copy all the files and folders in that tree except the machine generated backup files, and would maintain whatever permissions they had originally. It would also remove any files from the usb stick that no longer existed in the source folder tree. In other words it would maintain a mirror image, less the machine generated backups, of the /media/disk-2/office-backup/ folder tree.
This may not be what you wanted. It is just an example of the flexibility of the rsync command.
Like I said up front, I really need a better idea of what you are trying to accomplish in order to help you, instead of mislead you.
Fred
Re: Help with mv (move) command & crontab
Posted: Tue Aug 05, 2008 3:42 am
by miket
Hi !
kwisher wrote:AvanceIT wrote:
You've missed off the leading forward slash in the destination :
Code: Select all
mv /media/disk-2/office-backup/*.* /media/usb-bu/office-backup/
Your command line returns the following:
Code: Select all
mv: inter-device move failed: `/media/disk-2/office-backup/2008-08-03_15.48.32.201832.office.ful' to `/media/usb-bu/office-backup/2008-08-03_15.48.32.201832.office.ful'; unable to remove target: Is a directory
Since you put "*.*" in I assumed (incorrectly!!) you were only moving files and not directories as well !
The rsync suggestion that Fred has made would better suite your needs if you are trying to move directories as well ...
Mike.