MM HH DOM Month DOW CommandToExecuted
MM Minutes(0-59)
HH Hour(0-23)
DOM Day Of Month(0-31)
Month (1-12)
DOW (0-6)Sunday=0 weekday
Hello friends today i am going to write about how to house keep file system on Linux/Unix using crontab. file system housekeeping needed when there is not enough space on File system or it reached to its threshold value.
Let see one scenario where admin need to to house keep gzip files which are older than 100 days. so how he going to do this task ??
So in this situation admin need to first identify files which are old than 100 days and then need to remove from desired filesystem. here we can use following find command to identify .gz files which are older than 100 days.
#find /oracle/orausr -type f -mtime +100 -name "*.gz"
how to remove these files ??
answer is use following command
#find /oracle/orausr -type f -mtime +100 -name "*.gz" -exec rm {} \;
Till now we found way for finding and deleting *.gz file older than 100 days. but admin need to automate this by using crontab. also what if there are 1000 of server ?? so admin cant login to each server and delete these files, so in that situation crontab useful.
Crontab entry for scheduling above cron job is like below.
5 6 * * * find /oracle/orausr -type f -mtime +100 -name "*.gz" -exec rm {} \;
This crontab execute every day at 6:05 am for any gz files which are older than 100 days and delete the same file.
** before scheduling this cron please make sure that you tested it on test environment and mentioned correct path for file deletion.
Thanks !!!
No comments:
Post a Comment