1

I want to "code" a shell script which will do the following:

  • check for new folders in foler XYZ , will make a cron that opens the script every 30mins
  • if NEW folders found = use RAR and rar those folders like they are named . XYZ Main Folder:

-Blububb Changed: 7.03.2014 -> create rar -> Blubb.rar

#!bin/bash
for all in `find / -name "rpc-backup*" -type d -print`
do
#create archive
rar -a -k -v250000k /home/testuser/rar1.rar /home/testuser/rpc-backup1

done

So you see I dont have much so far , I need first of all a find command which looks only for new files or changed after the date (7.03.2014) , then also my rar process has to rar every folder he gets individual and not just one big rar where all my folders are in, i want a single rar for every single folder.

1
  • Just one question about your choice of tools. If you are on linux, why rar? Why not tar.gz or something standard like this? rar is not part of the core utilities, it's missing from most repositories, it has the wrong license and it is almost never used on linux. Not to mention it breaks file ownership.
    – orion
    Mar 10, 2014 at 11:08

2 Answers 2

2

for finding a file or folder that is new, find is your friend

find /folder/you/want -type d -ctime +10 -exec (your rar here)

look up your man pages for details on find, my examples above do not make sense

man find
0
#!bin/bash

#Creating a sample file with the reference date as its time stamp
touch -t 1403070000 /home/scripts/test/sample_file


for i in `find /home/scripts/test/ -type d -newer /home/scripts/test/sample_file -print`

# find /home/scripts/test/ -type d -newer /home/scripts/test/sample_file -print 
# displays all directories that are created after the reference date

do

        rar -a -k -v250000k /home/scripts/test/$i.rar /home/scripts/test/$i

done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .