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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

How will you print the login names of all users on a system?

955


State the advantages of shell scripting?

1041


Give some situations where typing error can destroy a program?

1234


How do we create command aliases in a shell?

982


Differentiate between ‘ and ” quotes.

1147


What is the command to find out users on the system?

956


What is the first line in every perl script called?

1025


What is shift command in shell script?

1012


Which scripting language is best for automation?

948


How does shell scripting work?

1088


Explain about return code?

1060


What's the difference between scripting and coding?

1161


Write a script to print the first 10 elements of fibonacci series.

2327


What is @echo off?

990


What does it mean by #!/Bin/sh or #!/Bin/bash at the beginning of every script?

1046