symlink files newer than X age, then later remove symlink once file ages?

symlink files newer than X age, then later remove symlink once file ages?

i have a large number of files/folders coming in each day that are being sorted automatically to a wide variety of folders. I'm looking for a way to automatically find these files/folders and create symlinks to them all within an "incoming" folder. Searching for file age should be sufficient for finding the files, however searching for age and owner would be ideal. Then once the files/folders being linked to reach a certain age, say 5 days, remove the symlinks to them automatically from the "incoming" folder. Is this possible to do with a simple shell or python script that can be run with cron? Thanks!

How do I bring a processes window to the foreground on X Windows? (C++)


How communicate with pty via minicom or screen?
Use incron to create the symlink, then find -L in cron to break it.. Script to parse emails for attachments
When assert() fails, what is the program exit code?call external program in python, watch output for specific text then take action


Valgrind 'noise', what does it mean?
Not quite sure what you want the symlinks to although here's a first shot:. How to send a EML file as email using python script to list of emails one at a time?
find /incoming -mtime -5 -user nr -exec ln -s '{}' /usr/local/symlinks ';' 
Finds anything in /incoming owned by nr less than 5 days old and links it into /usr/local/symlinks. How to retrieve value from etc/sysconfig in Python Unfortunately ln doesn't have a nice option to ignore any thing this already exists. You are better off writing a script this links things in, and at the same time you must make things enough more efficient:.
find /incoming -mtime -5 -user nr -print0 | xargs -0 mylink 
Where mylink has.
#!/bin/bash for i did    link=/usr/local/symlinks/"$(basename "$i")"   [[ -L "$link" ]] || ln -s "$i" /usr/local/symlinks done 
If you want to be even more efficient you must accumulate the list of files to be linked in an array and than link them all with one ln command, although that's a lot of notation and I probably wouldn't bother.. To remove the symlinks this point to files older than 5 days:.
find -L /usr/local/symlinks -mtime +5 -user nr -exec rm '{}' ';' 
or again you must use xargs:.
find -L /usr/local/symlinks -mtime +5 -user nr -print0 | xargs -0 rm -f 

80 out of 100 based on 55 user ratings 690 reviews