script me up baby!!

Soldato
Joined
7 Jan 2007
Posts
10,607
Location
Sussex, UK
hiya,

running xubuntu 9.04 but need a bash script from one of you linux masters.

What I want it to do is move all the contents of "/meda/disk1/finished/"

to

"/media/disk1/complete"

I need to run everyday at 8am automatically.

Can anyone be so kind as make me it? I assume it will need to go into init.d to get the schedule working?
 
Lazy boy! :p

Cron

Code:
#!/bin/bash

# This script moves the downloaded goat pr0n.

mv /meda/disk1/finished/* /media/disk1/complete


No idea how to use cron. That is left as an exercise for the OP. ;)

EDIT : beaten. Holy quick replies, Batman!
 
Lazy boy! :p

Cron

Code:
#!/bin/bash

# This script moves the downloaded goat pr0n.

mv /meda/disk1/finished/* /media/disk1/complete


No idea how to use cron. That is left as an exercise for the OP. ;)

EDIT : beaten. Holy quick replies, Batman!


oh yeh lol, didn't realise it was that easy rofl, how did you know it move goat pron?
 
Code:
mv: cannot move `/media/disk1/rofl/downloads/complete/TV/Prison Break' to `/media/disk1/TV/Prison Break': Directory not empty

How to fix? :s

I want the files added to the directory, not deleted.

Ps this is a DVD rip of a DVD i own so...
 
Team Powerlinux hang your heads in shame :p

rsync -a SOURCE/ DEST/ --remove-sent-files --ignore-existing --whole-file

that command works, it removes the files it copies over, and doesnt touch any other files.

I winzor
 
Surely since unix sees directories as files, that will do just the same thing...... Ie if his source dir contains a dir called prison break, and so does the dest, it just wont move prison break?
 
Surely since unix sees directories as files, that will do just the same thing...... Ie if his source dir contains a dir called prison break, and so does the dest, it just wont move prison break?

you would think, but it says permissions denied, Directory not empty

running this command:

mv /media/disk1/mybackups/complete/TV/* /media/disk1/TV/
 
you would think, but it says permissions denied, Directory not empty

running this command:

mv /media/disk1/mybackups/complete/TV/* /media/disk1/TV/

That's because the * at the end of the path tells it to move the directory itself.

That is, do an ls:

Code:
.
..
File.pr0n
More.pr0n
Dirty.pr0n
So it'll copy . - which is itself :)

At least I think that's what it's doing...
 
Last edited:
Surely since unix sees directories as files, that will do just the same thing...... Ie if his source dir contains a dir called prison break, and so does the dest, it just wont move prison break?

Ah no, you are in fact right - not me :)

cp can't move directories, you need to do it recursively, cp -r

But when all is said in done, rsync's better at doing the job you want so stick with that :p
 
BUT.........cp -r will overwrite subdirectories, not append to them..........eg


you have
/source/prisonbreak/
which contains
episode4
episode5
episode6

and of you have
/destination/prisonbreak/
Which contains
episode1
episode2
episode3

And you do
cp -r /source/* /destination/

You will end up with
/destination/prisonbreak/
containing only episodes 4 5 and 6


no?
 
BUT.........cp -r will overwrite subdirectories, not append to them..........eg


you have
/source/prisonbreak/
which contains
episode4
episode5
episode6

and of you have
/destination/prisonbreak/
Which contains
episode1
episode2
episode3

And you do
cp -r /source/* /destination/

You will end up with
/destination/prisonbreak/
containing only episodes 4 5 and 6


no?

copy it over will still leave the source files, thus duplicating data.

I found with the rcync way it only replaces files in destination that aren't there then deletes what it moves from source.

All I need to do now is work out how to change the owner of /media/disk1/ from root to my username. cos at mo the rsync command only works once sudo'd.
 
chown username.usergroup /media/disc1
(while unmounted)

If it's external media, you may also need to add your user to a group like "disc" or "dvd".

ta for that, I dunno fuppes is a PITA. Gonna try Arch linux, as there wiki is a lot better than ubuntu/ubuntuforums.org

It seems everything I do one little component wont work :/

Gonna give it a couple more days on this home server, if I cant get all i wanna work on arch linux, i'll be forced to just slap XP on it and be done with it.

/Angry Oxy
 
Back
Top Bottom