Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How to write an Auto scripting for deleting old files using
shell script and made a cron job to run on daily basis



How to write an Auto scripting for deleting old files using shell script and made a cron job to ru..

Answer / amit bondwal

#!/bin/bash
find /home/amitbondwal/ -type f -mtime +30 -exec rm -f {} \;
done
#change the directory path or name and number of days
#according to your requirement. This script will delete all
#the file older than 30 days in /home/amitbondwal directory

save the above script in a text file and run it by crontab

crontab -e

00 02 * * * /bin/sh /home/amitbondwal/scriptname.sh

This setting will run this script at 2 AM everyday.

Is This Answer Correct ?    12 Yes 0 No

Post New Answer

More Shell Script Interview Questions

Explain about non-login shell files?

0 Answers  


What is a boot block?

0 Answers  


Which is best institute for testing tool?

0 Answers  


what is the difference between sh & bash shell?

1 Answers  


1.Write a script, which converts a number from binary to hexadecimal format or vice versa.

1 Answers   ADP,


What are the advantages of shell script?

0 Answers  


What is scripting used for?

0 Answers  


There is a record with fields namely name,roll no.,salary,grade etc.Now,write a script to create a file with multiple records have same combination of fields but with unique roll numbers.The script should work for different names in the input file.

1 Answers   Wipro,


Write a shell script to looking at the log file to see if the test has passed or not

2 Answers   TCS,


Explain how you Automate your application using Shell scripting.

0 Answers   MAHINDRA,


What is awk in shell scripting?

0 Answers  


Write a shell script to check whether a number is Armstrong number or not?

1 Answers   Flipkart,


Categories