Help with mv (move) command & crontab

Questions about applications and software
Forum rules
Before you post please read this

Help with mv (move) command & crontab

Postby kwisher on Sun Aug 03, 2008 7:11 pm

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
The instructions suggested Windows XP or better, so I installed Linux :)
User avatar
kwisher
Level 5
Level 5
 
Posts: 634
Joined: Wed Mar 05, 2008 12:54 pm
Location: Greentown, Indiana USA

Linux Mint is funded by ads and donations.
 

Re: Help with mv (move) command & crontab

Postby miket on Mon Aug 04, 2008 5:13 am

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 :

Code: Select all
man crontab


It will outline everything there is know !
Any questions just drop a note here and I'll try and answer them for you ...

Mike.
User avatar
miket
Level 5
Level 5
 
Posts: 524
Joined: Tue Mar 04, 2008 5:50 am
Location: UK & France

Re: Help with mv (move) command & crontab

Postby kwisher on Mon Aug 04, 2008 4:45 pm

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
The instructions suggested Windows XP or better, so I installed Linux :)
User avatar
kwisher
Level 5
Level 5
 
Posts: 634
Joined: Wed Mar 05, 2008 12:54 pm
Location: Greentown, Indiana USA

Re: Help with mv (move) command & crontab

Postby Fred on Tue Aug 05, 2008 3:02 am

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
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: Help with mv (move) command & crontab

Postby miket on Tue Aug 05, 2008 3:42 am

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.
User avatar
miket
Level 5
Level 5
 
Posts: 524
Joined: Tue Mar 04, 2008 5:50 am
Location: UK & France


Return to Software & Applications

Who is online

Users browsing this forum: Bing [Bot], Google Adsense [Bot] and 20 guests