Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Using Mythbuntu, I need a script, that would make my dream alive...
Since i'm using wireless bridge, connected with my friends NAS, i tried to use it for streaming some movies to my Mythbuntu. Since the wifi connection manages only 500KB/s, i cannot stream some DVD movies etc.
And so... my idea is:
- make a automount folder on my Mythbuntu system
- every night rsync files/folders from that "mount_folder" to "copy_folder"
- BUT, since my "mount_folder" keeps growing (my NAS has some 2,5TB), and my "copy_folder" is only 120GB size, i would need to rsync only the latest files/folders, together 120GB...
Now, as much as i have seen, this is possible using "find" and "rsync" methods, but unfortunately...i have no idea, how to start, where to turn...
The first clears your box of all files older than say 1 week
The other uses the find command to find files less than 7 days old (use -ctime) and rsync them.
Evaluate how many GB/day you generate and adapt the time period accordingly.
Three fields in the inode structure contain the last access, change, and modification times: atime, ctime, and mtime. The atime field is updated each time the pointer to the file's data blocks is followed and the file's data is read. The mtime field is updated each time the file's data changes. The ctime field is updated each time the file's inode changes. The ctime is NOT creation time; there is no way under standard Unix to find a file's creation time.
You might find that mtime is just as good, if not better.
i want my crontab to exec these commands, so i want to insert following into it:
0 1 * * * find /mnt/Mythbuntu -type d -mtime 550 -exec rm {}
0 2 * * * find /mnt/nas -type d -mtime 550 -exec rsync -av {} /mnt/Mythbuntu
sorry for the late answer, a bit of work for the mo.
I'd put the above commands into a file and execute the file.
u need an 'r' to remore recursevely.
I think you are missing '\;' at the end of your find.
Code:
find /mnt/Mythbuntu -type d -mtime 550 -exec rm {} \;
You might want a '/' at the end of the rsync command for the destination.
Try something like this:
vi /usr/local/bin/myfile.sh
Code:
#!/bin/bash
find /mnt/Mythbuntu -type d -mtime 550 -exec rm -rf {} \;
find /mnt/nas -type d -mtime 550 -exec rsync -a {} /mnt/Mythbuntu/ \;
crontab -l
0 1 * * * /usr/local/bin/myfile.sh
I'm not sure your script will work though. might want to put an 'echo' in front of the 'rm' to make sure it doesn't remove important files.
#!/bin/bash
find /mnt/Mythbuntu -type d -mtime 550 -exec rm -rf {} \;
find /mnt/nas -type d -mtime 550 -exec rsync -a {} /mnt/Mythbuntu/ \;
Hi again!
Well... tried that... hmmm, really do not know what is there...
I start the script, ok at the beginning it gives me "FIND" errors, that it cannot find some of the files (generally, these files use long names and some "ä" etc... Think that could be the reason..? And also, these files are not inside some folders, but just files in mounted directory...
Then, it waits for few seconds (like it is searching something or...), and gives no add. info...
like:
Code:
ina@ina-desktop:/var/log/samba$ sudo sh /usr/local/bin/sincro.sh
find: `/videox/08-05-18 - PREMIERE 3 - Das Parfum - Die Geschichte eines M??rders (Perfume_ The Story of a Murderer.ts': No such file or directory
find: `/videox/08-05-20 - PREMIERE 1 - Basilisk - Der Schlangenk??nig (Basilisk_ The Serpent King) - Science-Fictio.ts': No such file or directory
find: `/videox/08-06-03 - PREMIERE 3 - Zoom - Akademie f?\254r Superhelden (Zoom) - Fantasykom??die.ts': No such file or directory
find: `/videox/08-06-10 - PREMIERE 3 - Friends with Money (Friends with Money) - Kom??die.ts': No such file or directory
find: `/videox/08-06-23 - PREMIERE 1 - Grandma_s Boy (Grandma_s Boy) - Kom??die.ts': No such file or directory
find: `/video/Butterfly.on.a.Wheel.2007.LIMITED.CUSTOM.SLOSUB.PAL.DVDR-?uroBits': No such file or directory
ina@ina-desktop:/var/log/samba$
Any ideas?
Oh, and the script is:
Code:
#!/bin/bash
find /videox -type d -mtime 600 -exec rm -rf {} \;
find /video -type d -mtime 600 -exec rsync -a {} /videox/ \;
What if I want to copy the files to a remote directory? I have the private/public keys setup already. I can log in without password. Here is what I am trying but it is not working,
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.