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

what is "umask"?

6 Answers   Wipro,


write a shell script to generate a alert ? like when ur birthday came then generate a alert ur birthday is today like that ?

0 Answers   Wells Fargo,


How to sort a result of Ls -l command based on columns. Ex. i want to sort 5th column from output of ls -l command.

6 Answers   TCS,


What does $1 mean in bash?

0 Answers  


Which shell is the best?

0 Answers  


What happens on a system call?

0 Answers  


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

0 Answers  


Can you write a script to portray how set –x works?

0 Answers  


How will you emulate wc –l using awk?

0 Answers  


defination of mapfile in winrunner?

0 Answers  


What does .sh file contain?

0 Answers  


What is the fastest scripting language?

0 Answers  


Categories