Hi,
I need to conver the date format to binary and then subract it by one which will result me an output with yesterdays date and use it..
So that i will use the out and delete all the folders which are of minus one days.i.e if today is 2010-03-18 (this is a folder format at some xyz location).
Now the script will search for the previous days folder and files in it and simply delete it....
Please help..
Now the variable $dir will have the yesterday's date value. This will be a directory name
means you can delete this directory and files in it using the following command
rm -rf ${dir}
If that directory is in some other path you need to specify the path exactly in the rm command's parameter.
but if this dir is at location say /usr/sam/pan/2010-03-17,
how will the script looks like..
I just need to put this is cront in such a way that it will search this folder 2010-03-17 and delete that and files in it..
This will be an on going process as deleting the folder and files manually i a big pain..
Also this folder get created everyday with todays date, so need to automate it and put in cron..
Have you checked the permissions for that directory?
And can you tell me... You told that one process is creating these directory and whether that process is owned by you?
yes ofcourse one proces creates this directory...
but as a trial iam creating the carbon copy of this directory at the root i.e/home/uat and then trying your script.
---------- Post updated at 03:21 PM ---------- Previous update was at 03:19 PM ----------
again i tried to change the permissions of the directory chmod 777 2010-03-17 and then again excuted, but still the directory exists there..
---------- Post updated at 03:33 PM ---------- Previous update was at 03:21 PM ----------
when is use the below code -
dir=`date +%Y-%m-%d --date='1 day ago'`
find /home/uat -iname $dir -exec rm -rf {} \;
This Delete the folder 2010-03-17
but throws an
ERROR -
find: /home/uat/2010-03-17: No such file or directory