Shell / Perl script to constantly comb a folder for new files & make copies of the new files

sunhux used Ask the Experts™

Refer to above EE link.  I have a similar requirement for RHEL 5/6 & Solaris as well, so
will need Shell / Perl scripts or any other solutions
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Distinguished Expert 2017
are you using qlemo's example, you can use a shell script that will use find -newer reference_file

if test ! -f "$Root_path/First_run" ; then
    cp -r "$Quarantine/*" "$Analysis"
    touch "$Root_path/First_run"
    touch "$Root_path/last_run"
find $Quarantine -newer "$Root_path/last_run" -exec cp {} "$Analysis/" \;
touch "$Root_path/last_run"

Open in new window

the above will deal with copying the quarantined items to the analysis destination without verification if the same file was previously quarantined/analysed...

the encryption what software are you considering for this?


The encryption software is from an AV product called qdecrypt which
encrypts infected files to make them harmless.

Yes, I'm looking at Qlemo scripts but just posted an update: if only
Qlemo's script track for the last date/time the script last stop/went
down, that will be perfect
Distinguished Expert 2017

You could add logging events that would write out to a file or a DB that the script ran, and finished......

In the above script echo $(date "%b-%d-%Y %H:%M:%s") started/stopped >> record_file

Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!


Or is there something you could add to the script that
will detect an "exit" or the script being killed like
(in the days I was doing VMS DCL scripting):

on error perform ...
on fatal_error perform ...
Distinguished Expert 2017
In a shell script you would use trap to detect signals and act accordingly.

You need to provide more context to the conditions, do not know VMS.
Adding logic to test conditions .....
nociSoftware Engineer
Distinguished Expert 2018
then there is the incron deamon, which can act on events like creation of a new file in a directory etc.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial