There is a large shared directory on a Linux machine that contains a number of projects. Once per day I need to determine if any new directories have been created since the previous day.
What would be the best way to go about doing this?
Does anyone have any suggestions? I am unable to install additional tools and would prefer a Bash script or something in Perl. Ideally, I would be able to access the file/directory creation date but it seems that only the date last modified is recorded.
I am trying to do something like this, but I can't seem to massage this to work properly. There must be a simple solution.
#!/bin/bash
cd /home/Project/working
if [ ! -e /tmp/new_games_diff_0 ]
then
echo "First run... cannot determine if there any new games"
ls -1 > /tmp/new_games_diff_0
exit
fi
ls -1 > /tmp/new_games_diff_1
gvimdiff /tmp/new_games_diff_1 /tmp/new_games_diff_0 &
cp /tmp/new_games_diff_1 /tmp/new_games_diff_0
You are correct - linux doesn't (necessarily) track any specific creation times. So you're going to need to compare 'before' and 'after.
Perl has a nice mechanism for this in the form of hashes, and the built in
Storable
module.If you want to store some file metadata in your db - like
mtime
then it'll be worth looking at thestat
function.However this might be a little overkill - as you might simply find that
find
will do the trick:(You can also use
-exec
as find option to perform an action on each of the files, like running a script).