Housekeeping Not Working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Housekeeping Not Working
# 8  
Old 05-27-2011
Hi Cero,

Yes, PATH Variable. The PATH has $HOME/bin included which has a value set and this gets appended when i run the script from command line.

But when the script is invoked via a batch procedure there is no value for $HOME and just /bin is getting appended into $PATH variable.

As you have highlighted in your earlier comment i have given the absolute path in my script now. Hopefully this should solve the problem when it runs the next time. finger crossed. Will update you soon.

---------- Post updated at 06:51 AM ---------- Previous update was at 06:49 AM ----------

one clarifitication

the command which i have used above, will first fetch all the directories and then sent as a bulk input to the rm command or the find fetches one row sends to rm, then fetches second row and send to rm.

can you clarify that doubt.

---------- Post updated at 07:06 AM ---------- Previous update was at 06:51 AM ----------

Hi Cero,

thanks for your valuable inputs and time. I have modified the script to include the absolute path as u have mentioned earlier.

Also the command i used "find * -depth -type d -ctime +84 -exec rm -rf {} \;" will first all the directories and sub directories and they are passed as bulk input to the rm command. Please correct if my understanding is wrong.

The reason for the above query is because when the child directory D12 is deleted the timestamp on D1 is changing to sysdate (i persume that the time i see in ls is mtime)
# 9  
Old 05-27-2011
The time you see in "ls -la" is indeed the equivalent of "-mtime".
The time you see in "ls -lac" is the equivalent of "-ctime".

Personally I would not base any processing on the value of "-ctime" found a directory timestamp. It is just the timestamp from when the inode was last changed. It is not unusual for "-ctime" to be more recent than "-mtime" in the same directory entry.
Some backup software changes this timestamp.


In fact the whole idea is dodgy because the "-ctime" stamp on a parent can be older than of the subdirectory ... and you are issuing "rm -r".

Last edited by methyl; 05-27-2011 at 01:44 PM..
# 10  
Old 06-01-2011
Hi Cero,

Thanks for the update once again.

Well i need to find all the directories older than x days and housekeep them. the problem i am facing is, only the child directory D12 is deleted and not the parent directory D1 when i use the command find * -depth -type d -ctime +84 -exec rm -rf {} \; (Both D1 and D12 are created on the same day)

My observation is when the child directory D12 is deleted, the ctime of parent directory D1 changes to sysdate and hence the above command does not list the parent directory as it doesnt satisfy the X days old condition. Am i right in my interpretation.
# 11  
Old 06-01-2011
Yes, you clear files by date and then empty directories.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

[Tip] Housekeeping Tasks Made Easy - User Home directories and Leftover Files

We have regularly questions about how to create users and user accounts. But regularly user accounts need to be deleted too. It is quite easy to delete the user account itself but usually the HOME directory of the user remains. It is good style to remove these directories but simply deleting... (3 Replies)
Discussion started by: bakunin
3 Replies

2. Shell Programming and Scripting

Disk Space Utilization in HTML format working in one environment and not working on the other

Hi Team, I have written the shell script which returns the result of the disk space filesystems which has crossed the threshold limit in HTML Format. Below mentioned is the script which worked perfectly on QA system. df -h | awk -v host=`hostname` ' BEGIN { print "<table border="4"... (13 Replies)
Discussion started by: Harihsun
13 Replies

3. AIX

Housekeeping null 2>&1 in /dev

Hello, Does anyone know how to housekeeping the null 2>&1 file in /dev? its fill up my system, please help. Thanks :b: (3 Replies)
Discussion started by: only
3 Replies

4. Shell Programming and Scripting

Working web service call not working with curl

Hello, Newbie here, I have a perfectly well working web service call I can issue from chrome (PC Windows 10) and get the results I want (a dimmer being turned on in Fibaro Home Center 2 at level 40) I am not allowed to post urls but the below works with http and :// and... (3 Replies)
Discussion started by: abigbear
3 Replies

5. HP-UX

Problems after filesystem housekeeping

I have noticed that after I clear up the /var filesystem, there are always problems. Does deleting the OLDsyslog.log file cause problems like missing directories and problems accessing crontabs? There were two situations where I faced problems. 1) Deleted OLDsyslog.log (Of course I created... (5 Replies)
Discussion started by: anaigini45
5 Replies

6. Shell Programming and Scripting

Automating pbrun /bin/su not working, whenever manually it is working using putty

I am trying to automate a script where I need to use pbrun /bin/su but for some reason it is not passing thru the pbrun as my code below. . ~/.bash_profile pbrun /bin/su - content c h 1 hpsvn up file path I am executing this from an external .sh file that is pointing to this scripts file... (14 Replies)
Discussion started by: jorgejac
14 Replies

7. Shell Programming and Scripting

Housekeeping script

I have a directory ( eg. /tmp , there are many files in it , I would like to do the houskeeping job , can advise how to develop a script to do the following . 1) if the files are elder than 10 days in this directory , the extension is .txt , then move it to /tmp/tmp-txt , the same , if the files... (2 Replies)
Discussion started by: ust3
2 Replies

8. Shell Programming and Scripting

Script not working in cron but working fine manually

Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered. The script is as follow: #!/bin/sh for file in file_1.txt file_2.txt file_3.txt do awk '{ print "0" }' $file > tmp.tmp mv tmp.tmp $file done And the cron... (2 Replies)
Discussion started by: jasperux
2 Replies

9. Shell Programming and Scripting

housekeeping

hey, I have to write a housekeeping script which would delete any files which are more than 10 days old, the file is named in such a fashion MYTEST20060101_182239.txt MYXML20060112_182879.xml MYEXCEL20060113_546321.xls If the current date is 20060112, then MYTEST20060101_182239.txt will be... (2 Replies)
Discussion started by: mpang_
2 Replies
Login or Register to Ask a Question